Making a program stop repeating
A loop repeats instructions. A while loop checks a condition before each round and repeats only while that condition is true. To make it stop, something must eventually make the condition false.
Before writing a loop, answer three questions: Where do I start? What changes each round? When should I stop?
Count down to a launch
Imagine a launch countdown: three, two, one, launch. If the announcer keeps saying three and never decreases the number, the launch never arrives.
The same thing can happen in a program. A condition is checked again, but checking it does not automatically change any values.
Write a stopping condition
# language: en
let remaining = 3
while remaining > 0:
say remaining
set remaining = remaining - 1
say "Launch!"
The initial value is three. Each round subtracts one. When the value reaches zero, remaining > 0 is false and the program continues after the loop. This example has no delay; the messages appear quickly.
Predict, then run
Will zero be printed by the loop?
3
2
1
Launch!
No. The next condition check happens before the loop could print zero. If the initial value were zero, the loop body would not run at all.
Your challenge
Start at five. Then change the rule to include zero and predict which comparison is needed. Trace both versions on paper so you can see exactly when they stop.
A common mistake
Forgetting the subtraction leaves remaining unchanged. That creates an infinite loop in the program’s logic. You do not need to run such a loop to investigate it: a trace table already shows the problem. If a program keeps running unexpectedly, use Stop.
Pliro has execution limits to help catch runaway work. Reaching a limit is a clue to check your stopping rule, not a reason to keep raising the limit. In an interactive game a loop can deliberately continue until a player exits, but it still needs an exit path and suitable waiting or event handling.
