Created
September 12, 2016 09:46
-
-
Save eszterkv/5cdd2f89ee4f4c76d4cbc736ca96d496 to your computer and use it in GitHub Desktop.
Generates a random hexadecimal color (e.g. #ff0000)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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