List check with the in operator
A list check uses in to accept a value only if it appears in a list of allowed values, e.g. choice in ['a', 'b']. Use not in to reject a value that is missing.
Understanding List check with the in operator in WA Computer Science ATAR Unit 1
What it does: A list check compares the input against a list of allowed values using in. The in operator tests whether a value appears in a list. A single = is assignment, not a check. 'x' is not one of the items in the list, so the in check gives False. The correct form is not in. Writing in not is a syntax error. Use lower() on the typed string, not on the list. Lists have no lower() method, so the second line would crash. input() returns a string, so the list must hold strings. The text '1' is not equal to the number 1.
Common mistakes: == compares a single string with the whole list, so it is never True. A list check needs the in operator: if choice in allowed:. The menu items are lowercase, so converting the input to uppercase means it can never match. Use .lower() for a case-insensitive check.
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 100–314) and word search (Modules 100–470).
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
inFill in the Blanks
Spot the Error
Student with a class code? Join your class →