> > Awesome! Now I can do it just like that: > > >>> dict([(chr(ord('a')+x),x) for x in range(2)]) > {'a': 0, 'b': 1} > > Thanks a lot! ;) >
Or dict((c, i) for (i, c) in enumerate('ab')) But at this point you could just use a dict comprehension. {c: i for i, c in enumerate('ab')}
-- http://mail.python.org/mailman/listinfo/python-list