Testing letters with isalpha() and isupper()
Returns True if the character ch is a letter, so a Caesar loop can shift letters and leave spaces and punctuation unchanged. ch.isupper() checks for capitals.
Understanding Testing letters with isalpha() and isupper() in ACARA Digital Technologies Years 9–10
What it does: The if statement runs the shifting code only when isalpha() is True. Spaces and punctuation skip it and are left as they are. isalpha() is a string method, so you call it with a dot after the character: ch.isalpha(). It returns True or False, so it works directly in an if. isupper() checks for capitals only. 'G'.isupper() is True, but 'g'.isupper() is False even though both are letters. isalpha() is the test a Caesar loop uses to decide whether a character is a letter that should be shifted.
Common mistakes: A for loop header must end with a colon. It should be: for ch in message:. isalpha is a method, so it needs brackets to run. Without them Python just checks that the method exists, so the test always passes. It should be: if ch.isalpha():.
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 860–875) and word search (Modules 860–944).
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
ch.isalpha()Fill in the Blanks
Spot the Error
Student with a class code? Join your class →