5.10. Mapping DelItem

5.10.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'}

5.10.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'}

5.10.3. Del Keyword

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

5.10.4. Assignments