The code for this exercise can be found in exercises/9-dictionaries/
.
You can manually run your code by clicking the play button, or:
$ cd ~/Desktop/2024-autumn-python-intro/exercises/9-dictionaries
$ python3 {FILE_NAME}.py
Task file: dictionaries.py
A student named Jack is using a dictionary to make a list of all the countries he wants to visit in the future, starting with their capital cities.
- Jack found a mistake in his dictionary. Can you fix it?
- Jack suddenly wants to visit Japan and Spain as well. Can you help him add the relevant entries to his dictionary?
- Jack doesn't want to go to France anymore. Can you update his dictionary to reflect this?
- Edit the for loop so it prints out all the countries and capitals Jack is visiting, and how many cities he visits in total.
Expected output:
$ python3 dictionaries.py
The capital of USA is Washington D.C.
The capital of China is Beijing
The capital of Japan is Tokyo
THe capital of Spain is Madrid
In the end, Jack visited 4 capital cities.