Skip to content

Instantly share code, notes, and snippets.

@y56
Created November 21, 2019 04:31
Show Gist options
  • Save y56/9b9250e5c96dd80dad2dfb0c18be9ba3 to your computer and use it in GitHub Desktop.
Save y56/9b9250e5c96dd80dad2dfb0c18be9ba3 to your computer and use it in GitHub Desktop.
to remove the last entry from orderedDict
from collections import OrderedDict
myOrderedDict = OrderedDict()
myOrderedDict['a'] = 1
myOrderedDict['b'] = 2
myOrderedDict.popitem(last = False) # Setting last to False signals you wanted to remove the first.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment