-
-
Save IndhumathyChelliah/eb7655fa0118fe9880a4dbae24d80e27 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
d1={'a':1,'b':2,'c':3} | |
#removes and returns the last inserted item in the dictionary | |
print (d1.popitem())#Output:('c', 3) | |
from collections import OrderedDict | |
d1=OrderedDict({'a':1,'b':2,'c':3}) | |
# by default,removes and returns the last inserted item in the OrderedDict | |
print (d1.popitem())#Output:('c', 3) | |
#if last=False,removes and returns the first inserted item in the OrderedDict. | |
print (d1.popitem(last=False))#Output:('a', 1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment