What one forgotten line turns a `while` loop infinite — and how do counters and user input make it stop on cue?
Short drills on what this video just taught. Write the code, run the checks, and reveal the answer only if you are stuck.
A variable n starts at 5 and a counter count starts at 0.
Write a while loop that runs while n is greater than 0, subtracting 1 from n each pass. Count how many times the body runs and leave that count in count.
Reassignment that ends the loop
Write the Lost Woods loop that reassigns where from input inside the body, and the loop printing x while n > 0 with n = n - 1, tracing n from 4 to 0.
Case-sensitive string comparison
Record that == compares strings exactly, with capitalized RIGHT unequal to right, note the lowercase-conversion workaround, and name != as the test for non-equivalence.
Recognizing and stopping a runaway loop
Write the countdown loop with n = n - 1 removed, add while True: as a guaranteed case, and list Ctrl-C, the red X, and interrupt kernel as the ways to stop it.
A counter tracking iterations
Write the sad-face version that sets n = 0 before the loop, puts n = n + 1 at the top of the body, and prints the face under if n > 2.