In [1]:
capitals = {'United States': 'Washington, DC','France': 'Paris','Italy': 'Rome'}

In [2]:
capitals['Italy']


Out[2]:
'Rome'

In [3]:
capitals['Spain'] = 'Madrid'
capitals


Out[3]:
{'France': 'Paris',
 'Italy': 'Rome',
 'Spain': 'Madrid',
 'United States': 'Washington, DC'}

In [4]:
capitals['Germany']


---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-4-02e66a1fa679> in <module>()
----> 1 capitals['Germany']

KeyError: 'Germany'

In [ ]:
'Germany' in capitals

In [ ]:
'Italy' in capitals

In [ ]:
morecapitals = {'Germany': 'Berlin','United Kingdom': 'London'}

In [ ]:
capitals.update(morecapitals)
capitals

In [ ]:
del capitals['United States']
capitals

In [ ]:
for key in capitals:
    print(key,capitals[key])

In [ ]:
for key in capitals.keys():
    print(key)

In [ ]:
for value in capitals.values():
    print(value)

In [5]:
for key,value in capitals.items():
    print(key,value)


United States Washington, DC
France Paris
Italy Rome
Spain Madrid

In [ ]: