Re-asking for input until it is valid
A REPEAT loop around INPUT that keeps asking for a value and shows an error message each time the check fails. The UNTIL condition is the valid range, so the loop ends only on valid data.
Understanding Re-asking for input until it is valid in IGCSE Computer Science Paper 2
What it does: The WHILE loop tests first, so INPUT must come before it. The condition is the invalid range, the opposite of the REPEAT UNTIL condition. The error message is only useful while the data is wrong. Put an IF inside the loop to OUTPUT the message when the check fails. After the loop the value is already valid.
Common mistakes: A number cannot be below 1 and above 10 at the same time, so the error message would never show. Invalid data is below the range OR above it: IF Num < 1 OR Num > 10 THEN. Inside the WHILE loop the program must ask again with INPUT Pts. Outputting the old value never changes Pts, so the loop would never end.
Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.
This module's key terms are also in a printable crossword (Modules 60–70) and word search (Modules 47–70).
Take this worksheet further — free with Cloodit
Each concept is reinforced from every angle — learned, then applied, then tested.
Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.
Over 100 of them, across seven natural biomes.
Turns their work into revision material ready for Flash Cards and Exam study.
Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.
Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.
Quick Questions
Match the Pairs
Key Term
REPEAT INPUT UNTIL validFill in the Blanks
Spot the Error
Student with a class code? Join your class →