CoursePython from Scratch to Intermediate · Module 5: Collections · part 35 of 75
Part 35 · Module 5: Collections

Lesson 3: Dictionaries, finding things by name instead of position

15 min read·14 Oct 2026
Module 5 · Lesson 3 · About 45 minutes · Needs: Module 5 Lessons 1 and 2 (lists, tuples, unpacking), Module 4 (if, for loops)

The situation

Amira's question for this module is "What is out, and who has it?". This morning she puts it more sharply. "If I read you a book id off the shelf list, say B06, tell me straight away who has it."

Nine copies are out today, Wednesday 14 October. With a Lesson 1 list you would walk along it until you met B06. Python has a collection built for this job: give it a name, and it gives you the thing filed under that name.

LIST: SEARCH BY POSITION DICTIONARY: GO BY KEY [0] B06 [1] B20 [2] B01 [3] B04 B06? check one by one "B06" "Jonah" one step, any size
A list makes you walk along it to find B06; a dictionary goes straight from the key to the value, in green because it is the answer.

The rest of this part opens with an account

Signing up is free and takes one email. Nothing to pay, and nothing renews.