Słownik odwrotny Pythona
inv_map = {v: k for k, v in my_map.items()}
Busy Boar
inv_map = {v: k for k, v in my_map.items()}
d = {'a':1, 'b':2, 'c':3}
inverted_d = {}
for k, v in d.items():
inverted_d[v] = k
>>> a = {0:'000000',1:'11111',3:'333333',4:'444444'}
>>> a.keys()
[0, 1, 3, 4]
>>> sorted(a.keys())
[0, 1, 3, 4]
>>> reversed(sorted(a.keys()))
<listreverseiterator object at 0x02B0DB70>
>>> list(reversed(sorted(a.keys())))
[4, 3, 1, 0]
inv_map = {v: k for k, v in my_map.iteritems()}
inv_map = {v: k for k, v in my_map.iteritems()}