← Python

For Loops

A for loop iterates over each item in a sequence one at a time

What it does: A for loop repeats a block of code once for each item in a sequence — a list, a string, or a range() of numbers. The loop variable (often i or x) takes each value from the sequence in turn, connected by the keyword in: for i in range(5):. Like an if statement, the line must end with a colon and the repeated code must be indented underneath it.

Common mistakes: Forgetting the trailing colon (for i in [1, 2, 3] instead of for i in [1, 2, 3]:) is the most common slip. It's also easy to forget that range(5) produces 0, 1, 2, 3, 4 — five numbers starting at 0, not 1 through 5.

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 does a for loop do?
Loops through each item in a sequenceLoops forever
Matches
❌ for x in range(5) print(x)
Error: Missing colon after for
Applying
Meanings
Term
for
Meaning
Loop that iterates through each item in a sequence.
Practice
for i in [1, 2, 3]:
Testing
Gaps
i in [1, 2, 3]:
Check Answer
Spots
1total = 0
2for i in [1, 2, 3]

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

The 'Chambered Nautilus' badge — File Explorer, 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 does a for loop do?
A. Loops through each item in a sequence ✓
B. Loops forever
for visits each item in a list, string, or range — one at a time
2. for x in [10,20,30]:\n print(x)\nWhat prints?
A. 30
B. 10, 20, 30 ✓
The loop visits every item in order — all three values print
3. for char in 'Hi':\n print(char)\nWhat prints?
A. H then i ✓
B. Hi
Looping over a string gives one character per iteration
4. What keyword follows 'for x'?
A. of
B. in ✓
The syntax is: for variable in sequence:
5. How many times does 'for i in range(3):' loop?
A. 3 times ✓
B. 4 times
range(3) produces 0, 1, 2 — three values, three iterations

Match the Pairs

for x in range(5) print(x) Error: Missing colon after for
for in range(5): print('hi') Error: Missing loop variable
for char in 'hello': print(char) Valid: Loop through string
for item in [1, 2, 3]: print(item) Ok: Loop through list
for i in range(3): print(i) Output: 0 1 2
total = 0 for n in [1,2,3]: total += n print(total) Output: 6

Key Term

for
Loop that iterates through each item in a sequence.~~in

Fill in the Blanks

1. for i in [1, 2, 3]: print(i)
2. for i in [1, 2, 3]: print(i)
3. for char in 'hello': print(char)
4. for color in ['red', 'blue']: print(color)
5. for i in range(5): print(i)

Spot the Error

Question 1
A total = 0
B for i in [1, 2, 3]
C total += i
D print(i)
E print('Sum:', total)
Line B — Missing colon at the end of the for line
Question 2
A total = 0
B for i in [1, 2, 3]:
C print(i)
D total += i
E print('Done')
Line C — The print line must be indented inside the for loop
Question 3
A total = 0
B For i in [1, 2, 3]:
C total += i
D print(i)
E print('Sum:', total)
Line B — for must be lowercase: For is not valid Python
Question 4
A total = 0
B for i of [1, 2, 3]:
C total += i
D print(i)
E print('Sum:', total)
Line B — Use 'in', not 'of': Python syntax is: for x in sequence:
Question 5
A total = 0
B for i in 5:
C total += i
D print('Sum:', total)
Line B — Can't loop over a plain number: use range(5) to loop 5 times
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?