Skip to content

Instantly share code, notes, and snippets.

@eszterkv
Created September 12, 2016 09:46
Show Gist options
  • Save eszterkv/5cdd2f89ee4f4c76d4cbc736ca96d496 to your computer and use it in GitHub Desktop.
Save eszterkv/5cdd2f89ee4f4c76d4cbc736ca96d496 to your computer and use it in GitHub Desktop.
Generates a random hexadecimal color (e.g. #ff0000)
def random_hexcolor():
color = '#'
while len(color) < 7:
hex = '{0:x}'.format(random.randrange(256))
if len(hex) < 2:
hex = '0' + hex
color += hex
return color
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment