from random import randint
random_color = randint(0,256**3-1)
print "#" + str(hex(random_color))[2:].zfill(6)
#or
from random import randint
heks = randint(0,256**3-1)
print "#%.6x" % heks
#or
from random import randint
bytes3 = []
for i in range(3):
byte_ = randint(0,255)
bytes3.append(byte_)
print "#%.2x%.2x%.2x" % (bytes3[0],bytes3[1],bytes3[2])
I found at least three ways to make random hex color code in Python and of course there are million ways to do same thing.