Lesson 4: Nested data and comprehensions, the whole catalogue
17 min read·14 Oct 2026
Module 5 · Lesson 4 · About 50 minutes · Needs: Module 5 Lessons 1 to 3 (lists, tuples and sets, dictionaries), Module 4 (for loops, if)The situation
Amira wants the whole shelf in the computer, so she can ask it things. "Which books are gothic? How many of each genre? Which have two copies?"
One book fits in one dictionary; the shelf is 24 of them. This lesson puts collections inside collections, reaches into them step by step, and shows a short way to build a new list from an old one. We follow one book throughout: B06, Frankenstein, the copy Jonah has out.