0

If:

for k in ['a', 'b', 'c', 'd']: print k
a
b
c
d

Then why when creating a ordered dictionary order is different:

from collections import OrderedDict

OrderedDict({k: k for k in ['a','b','c','d']})
OrderedDict([('a', 'a'), ('c', 'c'), ('b', 'b'), ('d', 'd')])
Brad Solomon
  • 38,521
  • 31
  • 149
  • 235
Rob
  • 415
  • 4
  • 12

0 Answers0