Skip to content

Instantly share code, notes, and snippets.

@richardjpope
Last active August 29, 2015 14:10
Show Gist options
  • Save richardjpope/789debb25ae64a373d4c to your computer and use it in GitHub Desktop.
Save richardjpope/789debb25ae64a373d4c to your computer and use it in GitHub Desktop.
String to colour in python
def string_to_colour(s):
s = s.lower()
r = ((ord(s[0])-96.0)/26)*255
g = ((ord(s[int(len(s)/2)])-96.0)/26)*255
b = ((ord(s[len(s)-1])-96.0)/26)*255
return '#%02X%02X%02X' % (r,g,b)
@richardjpope
Copy link
Author

:)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment