len() function
len() returns the number of characters in a string (or items in a sequence)
What it does: 'Python' has 6 characters, so len() returns 6. The empty string has zero characters, so len('') returns 0. Count each character: H-e-l-l-o = 5. H-i = 2 characters. Count including the space: H-e-l-l-o-space-W-o-r-l-d = 11. A space is a character — len() counts everything between the quotes. A-l-i-c-e = 5 characters. len() returns a whole number — the count of characters.
Common mistakes: Line 2 is missing parentheses. Should be: length = len(name). Line 2 puts the variable in quotes. Should be: len(word).
Free printable worksheet with full answer key — or add this module to a journey and assign it to your class.
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
len("Hello")?len("Hi")?len("Hello World")?len()?name = "Alice", what is len(name)?Match the Pairs
Key Term
len("Hello")Fill in the Blanks
Spot the Error
Create a free class, add this module to a journey, and track who's stuck.
Create a free teacher account →No credit card. No setup fee. Make a class and invite students in under three minutes.
Practice this topic interactively, track progress, and unlock badges.
Start Learning Free →