← Python

Nested Lists

A nested list is a list that contains other lists as its elements

What it does: Sets automatically remove duplicate values — each item appears only once. Use set() for an empty set. .add() inserts one element. {} creates an empty dict, not a set — you must use set(). Sets have no guaranteed order, so s[0] doesn't work — use in to check membership. .append() is for lists; sets use .add() to insert a single item. Sets don't support index-based pop — use .remove() or .discard() by value. in checks membership — 3 is in the set so it returns True. len() counts the number of unique items in the set.

Common mistakes: {} creates an empty dict, not a set. Use set() for an empty set. Sets use .add(), not .append() (that's for lists).

Class: _____________________  ·  Name: _____________________  ·  Date: _________

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.

Learning
Duo
What makes a set special?
Items are unique no duplicatesItems are ordered
Matches
❌ s = {1, 2, 3} print(s[0])
Error: Sets have no index
Applying
Meanings
Term
Set
Meaning
An unordered collection of unique items in curly braces.
Practice
colors = {'red', 'blue', 'green'}
Testing
Gaps
s = ()
Check Answer
Spots
1# Create an empty set
2s = {}

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Platinum Fox' badge — Tundra Legend, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. What makes a set special?
A. Items are unique no duplicates ✓
B. Items are ordered
Sets automatically remove duplicates — great for deduplication tasks
2. How do you create an empty set?
A. {}
B. set() ✓
{} creates an empty dict, not a set — you must use set()
3. {1, 2, 2, 3} becomes?
A. {1, 2, 3} ✓
B. {1, 2, 2, 3}
Sets silently drop duplicate values — 2 appears only once
4. Can you access set items by index?
A. Yes like lists
B. No sets are unordered ✓
Sets have no guaranteed order, so s[0] doesn't work — use in to check membership
5. How do you add to a set?
A. .add() ✓
B. .append()
.append() is for lists; sets use .add() to insert a single item

Match the Pairs

s = {1, 2, 3} print(s[0]) Error: Sets have no index
empty = {} Error: {} creates dict, not set
s = {1, 2, 2, 3} Valid: Becomes {1, 2, 3}
s = set() s.add(5) Ok: Empty set then add 5
s = {3, 1, 2, 1} print(len(s)) Output: 3
s = {1, 2, 3} print(2 in s) Output: True

Key Term

Set
An unordered collection of unique items in curly braces.~~set()

Fill in the Blanks

1. s = set()
2. s = {1, 2, 3} s.add(4)
3. s = {1, 2, 3} s.discard(2)
4. print(3 in {1, 2, 3})
5. s = {1, 2, 2, 3} print(len(s))

Spot the Error

Question 1
A # Create an empty set
B s = {}
C s.add(1)
D print('Set:', s)
Line B — {} creates an empty dict, not a set. Use set() for an empty set.
Question 2
A s = {1, 2, 3}
B s.append(4)
C print('Set:', s)
D print('Done')
Line B — Sets use .add(), not .append() (that's for lists)
Question 3
A s = {1, 2, 3}
B first = s[0]
C print('First:', first)
D print('Done')
Line B — Sets are unordered: you can't access items by index
Question 4
A s = {1, 2, 3}
B s.remove(5)
C print('Set:', s)
D print('Done')
Line B — 5 is not in the set: remove() raises KeyError. Use discard() instead.
Question 5
A s = {[1, 2], [3, 4]}
B label = 'Coords'
C print('Set:', s)
D print('Done')
Line A — Lists can't be in sets (unhashable). Use tuples instead.
For Teachers

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.

For Students

Practice this topic interactively, track progress, and unlock badges.

Start Learning Free →

Have a class code?