OrderedDict in Python-question-10

Last Updated :
Discuss
Comments

What will the following code output?

Python
from collections import OrderedDict
d = OrderedDict([('a', 1), ('b', 2), ('c', 3)])
d.move_to_end('b', last=False)
for key, value in d.items():
    print(key, value)

b 2, a 1, c 3


a 1, c 3, b 2

a 1, b 2, c 3

c 3, b 2, a 1

Share your thoughts in the comments