Caffeinated Coder
Book an appointment
Lesson 08 · First steps in code

Loops: doing things again

Programs are good at doing the same thing many times without getting bored. A loop runs a block of lines again and again. Step through a short Python program: a for loop adds up 1 + 2 + 3 + 4, the highlight jumps back to the loop's first line after every pass, and the numbers in memory change each time. Then see a while loop stop when its condition turns False, and how break gets you out of a loop that would never end.

10 min10 steps5 questionsBeginner
Fig 8 · Interactive
Loading figure…
or ← →

Quiz Unlocks after the last step.