Working with strings

About this lesson: Working with strings

In short

len() counts the characters in a string, including spaces. upper() and lower() change the case. Try three strings.

Working with strings

What you'll explore

String functions: Length and case
len() counts the characters in a string, including spaces. upper() and lower() change the case. Try three strings.
Comparing answers: YES, Yes or yes?
"YES" == "yes" is False, because capitals are different characters.
Checking input: Is the name long enough?
A program can use len() to check a name has 2 to 12 letters before accepting it. Try three names.
Check yourself: Length
word = "Hi there"

Also in this lesson

  • Common mix-ups
  • String tools
  • Password checker

Words to know

string
A sequence of characters.
character
A single letter, digit, space or symbol.
len()
Gives the number of characters.
case
Whether letters are capitals or small.
validation
Checking that input is sensible.

Sources

  • BBC Bitesize KS3 Computer Science
  • Raspberry Pi Foundation, Computing curriculum resources

An interactive lesson with a live experiment: move the sliders, press the buttons and answer quick questions. 4 short steps and a 6-question quiz. Part of the Family plan. Written and checked by Shalo Lab. Last updated 11 November 2026.

← Arrays and indexes · Sequence, selection and iteration together →

All lessons in Term 1 · Computing · Age 13