for and range
Lesson 9 of 20 · Py.Micro
Repeat a block once for each value in a sequence.
for i in range(3): runs the block with i = 0, then 1, then 2. Watch i change in the step by step panel.
Check yourself
What does list(range(1, 4)) give?
Do it in the browser: a real Python tool, a short mission and instant feedback. No install.
Start this lesson — free