1. Learn
  2. /
  3. Courses
  4. /
  5. Intermediate Python for Data Science

Connected

Exercise

Motivation for dictionaries

To see why dictionaries are useful, have a look at the two lists defined on the right. countries contains the names of some European countries. capitals lists the corresponding names of their capital.

Instructions

100 XP
  • Use the index() method on countries to find the index of 'germany'. Store this index as ind_ger.
  • Use ind_ger to access the capital of Germany from the capitals list. Print it out.