A debugger lets you inspect a program while it runs, helping you find bugs and understand how execution changes variable state. It complements print statements and can reveal why code produces an unexpected result. section 8.0 section 8.9
A practical debugging workflow is:
- Run the failing test or example and reduce the investigation to the smallest useful case. section 8.5
- Form a hypothesis about which update or condition is wrong, then place a breakpoint near it. section 8.5
- Use Continue and Step Over while watching variables and the current input; confirm or reject the hypothesis. section 8.5
- Correct the code, rerun the test, and restore any tests temporarily set aside. section 8.9
Counting consecutive students
A function is expected to return 4 for a row containing four consecutive students, but its doctest returns 3. Stepping through the loop shows that count reaches 4 only at the final seat; the code updates max_count only when an empty seat is encountered, so the final run is never recorded. Moving the update inside the student branch fixes the function. section 8.5





