Skip to content

Latest commit

 

History

History
28 lines (23 loc) · 1.07 KB

9-dictionaries.md

File metadata and controls

28 lines (23 loc) · 1.07 KB

📕 Dictionaries 🌟

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 9.1: Around the world

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.

  1. Jack found a mistake in his dictionary. Can you fix it?
  2. Jack suddenly wants to visit Japan and Spain as well. Can you help him add the relevant entries to his dictionary?
  3. Jack doesn't want to go to France anymore. Can you update his dictionary to reflect this?
  4. 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.