-
-
Save IndhumathyChelliah/11affa56702c09fe117a7126ce556e56 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import OrderedDict | |
d1=OrderedDict({'a':1,'b':2,'c':3}) | |
d1.move_to_end('b') | |
#It moves the key -'b' to the end.By default last=True | |
print (d1)#Output:OrderedDict([('a', 1), ('c', 3), ('b', 2)]) | |
d1.move_to_end('c',last=False) | |
#Since last=False, it moves the key 'c' to beginnning of ordered dictionary. | |
print (d1)#Output:OrderedDict([('c', 3), ('a', 1), ('b', 2)]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment