Removing Things from a Dictionary
You need to remove an item from a dictionary.
Use the pop command, specifying the key for the item that you want to remove:
>>> phone_numbers = {‘Simon’:’01234 567899′, ‘Jane’:’01234 666666′} >>> phone_numbers.pop(‘Jane’) ‘01234 666666’ >>> phone_numbers {‘Simon’: ‘01234 567899’} |
Discussion
The pop command returns the value of the item removed from the dictionary.
See Also
All the recipes between Recipes 6.12 and 6.15 involve the use of dictionaries.