Python is a powerful general-purpose programming language.

Python OrderedDict not keeping element order

Question or problem about Python programming: I’m trying to create an OrderedDict object but no sooner do I create it, than the elements are all jumbled. This is what I do: from collections import OrderedDict od = OrderedDict({(0,0):[2],(0,1):[1,9],(0,2):[1,5,9]}) The elements don’t stay in the order I assign od OrderedDict([((0, 1), [1, 9]), ((0, 0), [2]), […]

Continue Reading