Sets – Basics
A set is an unordered collection of unique values defined with curly braces or set()
What it does: g[0] is [1,2], then [1] gives the second item: 2. A nested for loop visits every element in every inner list. Any list item can itself be a list — nesting creates multi-dimensional structures. grid[0] gets the first inner list — a second index is needed to get a number. grid[1] is [3,4], then [0] picks the first item — which is 3. len() counts the top-level items — there are 2 inner lists, not 4 numbers. Rows and columns map naturally to a list of lists. Lists are mutable — you can assign to any index including nested ones.
Common mistakes: Use two separate brackets grid[0][1], not a comma grid[0, 1]. grid has indices 0 and 1. Index 2 is out of range.
Free printable worksheet with full answer key — or add this module to a journey and assign it to your class.
Take this worksheet further — free with Cloodit
Each concept is reinforced from every angle — learned, then applied, then tested.
Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.
Over 100 of them, across seven natural biomes.
Turns their work into revision material ready for Flash Cards and Exam study.
Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.
Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.
Quick Questions
Match the Pairs
Key Term
Nested listFill in the Blanks
Spot the Error
Create a free class, add this module to a journey, and track who's stuck.
Create a free teacher account →No credit card. No setup fee. Make a class and invite students in under three minutes.
Practice this topic interactively, track progress, and unlock badges.
Start Learning Free →