Lesson 2: for loops, the same steps for every loan
16 min read·14 Oct 2026
Module 4 · Lesson 2 · About 45 minutes · Needs: Module 4 Lesson 1 (if,elif,else), Module 3 Lesson 2 (splitandsplitlines), Module 2 (int(),+=,min())
The situation
Amira wants an answer for the whole shelf, not one loan: "Which of these twelve loans are overdue, and what is owed?" In Lesson 1 you decided whether one loan was overdue. Ben's loan, L13,B20,Ben,21,, was due on shelf day 35, and today is day 44, so he is 9 days late and owes 180 pence.
Copying that code twelve times would work, with twelve chances for a typing slip. This lesson teaches the for loop: write the steps once, and Python repeats them for every loan.