The easiest way is to list all numbers from 0 to 15, formatted as hex:
["{:x}".format(x) for x in range(0,16)]
GarbageCollector suggested a good alternative to comments that should be adapted to remove redundant upper case characters:
>>> import string
>>> string.hexdigits
'0123456789abcdefABCDEF'
>>> string.hexdigits[:16]
'0123456789abcdef'
to get the list:
>>> list(string.hexdigits[:16])
the fact that the character order remains unchanged in string.hexdigits
a future version of python is unknown. It’s still nice to know that it string
contains several useful groups of characters.
source
share