0

Is there a way to create a series of hex colors in python not mannually, for example ranging from dark green through light green and light yellow to dark yellow. Something like the following but not writing down all the hex code:

#from dark yellow ---> dark green
colors = ['#ffff00','#ffffcc','#d6f5d6','#99e699','#85e085','#70db70','#5cd65c','#47d147','#33cc33','#2eb82e','#248f24','#1f7a1f','#196619','#145214','#0f3d0f']

I would imagine something like range() for numbers.

Mpizos Dimitris
  • 4,819
  • 12
  • 58
  • 100
  • Not exact duplicate, but this [question](http://stackoverflow.com/q/25668828/1377864) probably contains enough information to solve your problem. – Yaroslav Admin Feb 25 '16 at 13:45

1 Answers1

2

Well the hex color is just a hex representation of 3 decimal values(0 to 255). For instance for green you could do something like:

>>> ["#{val}FF{val}".format(val=hex(i)[2:].zfill(2)) for i in range(55, 255, 50)]
['#37FF37', '#69FF69', '#9bFF9b', '#cdFFcd']
Alexander Ejbekov
  • 5,594
  • 1
  • 26
  • 26