6.9. Mapping DelItem

6.9.1. Pop Method

>>> crew = {
...    'commander': 'Melissa Lewis',
...    'botanist': 'Mark Watney',
...    'pilot': 'Rick Martinez',
...    'chemist': 'Alex Vogel',
...    'surgeon': 'Chris Beck',
...    'engineer': 'Beth Johanssen'}
>>>
>>>
>>> left_alone_on_mars = crew.pop('botanist')
>>>
>>> print(left_alone_on_mars)
Mark Watney
>>>
>>> print(crew)  
{'commander': 'Melissa Lewis',
 'pilot': 'Rick Martinez',
 'chemist': 'Alex Vogel',
 'surgeon': 'Chris Beck',
 'engineer': 'Beth Johanssen'}

6.9.2. Popitem Method

>>> crew = {
...    'commander': 'Melissa Lewis',
...    'botanist': 'Mark Watney',
...    'pilot': 'Rick Martinez'}
>>>
>>>
>>> last = crew.popitem()
>>>
>>> print(last)
('pilot', 'Rick Martinez')
>>>
>>> print(crew)
{'commander': 'Melissa Lewis', 'botanist': 'Mark Watney'}

6.9.3. Del Keyword

>>> crew = {
...    'commander': 'Melissa Lewis',
...    'botanist': 'Mark Watney',
...    'pilot': 'Rick Martinez'}
>>>
>>>
>>> del crew['pilot']
>>>
>>> print(crew)
{'commander': 'Melissa Lewis', 'botanist': 'Mark Watney'}