A Python loop question is solved with a trace table, not in the head. The table has one column for each changing variable, one for the condition and one for the output, and one row for each change. Control structures (Syllabus 9.8, page 39) (විෂය නිර්දේශය 9.8, පිටුව 36) appear in all eight new-syllabus papers, with 17 MCQs and 59 Paper II marks, and most of them start with a trace.
2023 (held 2024) Paper I, Q43 shows why. i starts at 7, and the loop subtracts 3, prints a star, then either breaks (when i is 2 or less) or prints a second star. The trace has two rows. Row 1: i = 4, one star, 4 is not 2 or less, so a second star. Row 2: i = 1, a third star, then break. The answer is 3 stars, option (2), our own worked answer. A trace in the head often drops the star printed just before the break, or the star from the else. The table keeps every line that ran, so nothing is dropped.
So draw the table, even for a short loop. The full method, with range(), sentinel loops, break, continue, nested loops and the loop else, is in Python loop tracing with trace tables.
