When `break` fires inside nested loops, which loop actually stops — and what happens to the code left below it?
Short drills on what this video just taught. Write the code, run the checks, and reveal the answer only if you are stuck.
Loop over range(8) and count how many of those values are even (0 counts as even). Assign the total to even_count.
Hint: the remainder operator % gives the leftover after division, and == 0 checks whether a number divides evenly.
Natural end of a while loop and a for loop
Write the rule that a while loop stops once its condition becomes false and a for loop stops once its sequence of values is exhausted.
break exits the innermost surrounding loop
State that break leaves only the loop immediately around it and never an enclosing if, then trace the for i in range(5, 11, 2) example line by line to the printed 5.
Counting with a counter initialized before the loop
Write the three-line even-number counter with even_nums = 0, for i in range(5) and if i % 2 == 0, and record the outputs 3 for range(5) and 5 for range(10).