I've run into a problem with looping through a dictionary. The following code:
d = {}
d['a'] = 1
d['b'] = 2
d['c'] = 3
for k,v in d.iteritems():
print k,v
Results in:
a 1
c 3
b 2
But the desired result is:
a 1
b 2
c 3
Does anyone know how to fix the loop somehow to preserve the order that the elements were assigned in? Thank you!