loop
← All sections

Module 4 · Functions, tuples, dictionaries, exceptions, and data processing

Tuples and dictionaries

Two more collections, each with a superpower lists don't have. Tuples are fixed and safe; dictionaries look things up by name instead of position. Meet mutability, then both types — and watch them team up.

Begin lesson 1 →
  1. 1Sequence types and mutabilityThe big divide: values you can change after creating them, and values you can't.
  2. 2TuplesFixed, ordered collections — created with commas, read by index, and unpacked in one line.
  3. 3DictionariesLook things up by a key instead of a position: the key → value mapping.
  4. 4Dictionary methods and functionskeys(), values(), items(), get() and in — the everyday dictionary toolkit.
  5. 5Tuples and dictionaries togetheritems() hands back tuples — so looping a dictionary is tuple unpacking in disguise.
  6. 6QuizCheck your grip on mutability, tuples, dictionaries and their methods.