Lesson 1: One loan at a time with iterators and generators
15 min read·14 Oct 2026
Module 10 · Lesson 1 · About 50 minutes · Needs: Module 8 (reading files, CSV,tryandexcept), Module 7 (thebooknookpackage anddatetime), Module 5 (lists and comprehensions)
The situation
Amira's request for this module is "Make sure it never breaks." Her first worry is size. "Forty loans is nothing. Will the program cope with years of loans?"
So far every function built a whole list, then handed it over. This lesson teaches a second way: hand over one loan at a time, only when asked. You will follow the rows of data/loans.csv one at a time until the four overdue loans come out: Jonah's L04, Ben's L13, Kwame's L21 and Lena's L23.