The popitem() method has an optional last argument that defaults to True. If last is true, the most recently added key is returned and removed; if it’s false, the oldest key is selected: >>> >>> od = OrderedDict([(x,0) for x in range(20)]) >>> od.popitem() (19, 0) >...