Python Quest

Track 6 · Lesson 5 of 12

Dictionaries: looking things up by key

Store values under meaningful keys, read them safely with get(), and add, update and delete entries.

About 40 minBeginner4 exercises

You will be able to

  • Create a dictionary and read a value by its key
  • Explain when a KeyError happens and avoid it with in or get() with a default
  • Add, update and delete entries, and check the number of entries with len()
  • Write functions that look up and update dictionaries without crashing on missing keys

Included with a Formula Quest membership

It has 4 graded exercises with feedback, hints and solutions. Python Quest is included in Formula Quest memberships that cover Python; membership and billing are managed on Formula Quest.

View Formula Quest memberships

Tracks 1 and 2, the first lesson of every track, the playground and the dataset library are free.