Part 3 · Section 03

Dictionaries

The dictionary is the most important data structure in Python. Your modules, classes and instances keep their attributes in dicts, keyword arguments arrive as a dict, and most real programs use them everywhere for lookups, counting, grouping and configuration. A dict maps keys to values, and it can find the value for a key in roughly constant time no matter how many items it holds. That speed comes from a hash table, and understanding how it works explains every rule dictionaries impose: why keys must be hashable, why lists can’t be keys, and why __eq__ and __hash__ must agree.

In this section you’ll learn:

Lectures

  1. 01Creating Python Dictionaries✓
  2. 02Common Operations✓
  3. 03Dictionary Views✓
  4. 04Updating, Merging and Copying✓
  5. 05Custom Classes and Hashing✓

Practice: quiz & exercises

12 quiz questions · 4 coding exercises

Go to practice →