Lesson 3: while loops, and how to stop them
16 min read·14 Oct 2026
Module 4 · Lesson 3 · About 45 minutes · Needs: Module 4 Lessons 1 and 2 (if,elif,else,and,forloops,range())
The situation
Amira has Ben's loan, L13, in her hand. "He borrowed The War of the Worlds on day 21. How many days late is he today?" Tom adds a worry: he sometimes types nine instead of 9 into the fee program, and it stops with an error.
Both jobs repeat a step until something becomes true: count one more day until today, ask again until the answer is a number. The while loop is made for that.