Inspired Python
◆◆◆
>>> d = {"favorite_food": "Pizza", "favorite_drink": "Coffee"}
>>> d.pop("favorite_food")
'Pizza'
# Missing elements raise KeyError, like you would expect.
>>> d.pop("favorite_music")
KeyError: 'favorite_music'
# ... but like the get() method you can specify a default.
>>> d.pop("favorite_language", "Python")
'Python'
>>> d['favorite_city'] = "London"
>>> d.popitem()
('favorite_city', 'London')