Dictionary Manipulation (2)
Somebody thought it would be funny to mess with your accurately generated dictionary. An adapted version of the europe
dictionary is available in the script.
Can you clean up? Do not do this by adapting the definition of europe
, but by adding Python commands to the script to update and remove key:value pairs.
This exercise is part of the course
Intermediate Python
Exercise instructions
- The capital of Germany is not
'bonn'
; it's'berlin'
. Update its value. - Australia is not in Europe, Austria is! Remove the key
'australia'
fromeurope
. - Print out
europe
to see if your cleaning work paid off.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Definition of dictionary
europe = {'spain':'madrid', 'france':'paris', 'germany':'bonn',
'norway':'oslo', 'italy':'rome', 'poland':'warsaw',
'australia':'vienna' }
# Update capital of germany
# Remove australia
# Print europe