0

I am porting my code from python2 to python3, but having problem with common function which lists the web page elements in order. In python2 it returned a different order, and my code was using by index, so now they are breaking. How can I fix this

Basically, in python2,

myDict = {'One': 1, 'Two': 2, 'Three': 3}
print (myDict.items())

[('Three', 3), ('Two', 2), ('One', 1)]

In python3,

myDict = {'One': 1, 'Two': 2, 'Three': 3}
print (list(myDict.items()))

[('One', 1), ('Two', 2), ('Three', 3)]

Why is there this difference and how can I fix it? Do I just reverse the list or is there a better fix? thanks!

golu
  • 629
  • 2
  • 7
  • 18

0 Answers0