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.

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
← Arrays and indexes · Sequence, selection and iteration together →