A menu loop to control user interactions
Starts a menu loop that repeats forever: show options, read a choice, call the matching function with if/elif, reject invalid input, and break when the user picks quit.
Understanding A menu loop to control user interactions in QCE Digital Solutions Unit 3
What it does: The else runs only when no if or elif matched, so the user sees an error message and the loop shows the menu again. The user must see the options and enter a choice before the program can decide which function to call. Use == to compare values. A single = is assignment and causes a syntax error in a condition. An if/elif chain checks the options in order and stops at the first match. A final else handles every other choice. Handling an invalid choice means the loop continues. The user gets feedback and another chance to choose. while True repeats forever unless something such as break stops it. Every menu needs a quit option.
Common mistakes: A single = assigns a value and is not allowed in an if condition. Use == to compare the user's choice with "1". The input() call is missing its closing bracket, which causes a SyntaxError. It should end with ) like this: input("Choice: ").
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 251–337) and word search (Modules 194–337).
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
while True:Fill in the Blanks
Spot the Error
Student with a class code? Join your class →