Year 10 (ages 14–15, Grade 9 in the US) · Computing · GCSE programming · Lesson 6
String handling
Working with strings in Python: length, indexing from zero, slicing, upper and lower case, concatenation, looping through characters, and character codes with ord() and chr().
Exam boards: this lesson matches the AQA and Pearson Edexcel GCSE computing courses. Check which course your school follows.

8-minute video lesson
Teaching, worked examples and 20 practice questions solved step by step.
Watch free for a monthWhat your child will learn
- Find the length of a string
- Use indexing and slicing
- Change case and join strings
- Use ord() and chr()
The method
- len(s) gives the number of characters.
- Indexes start at 0: s[0] is the first character.
- s[a:b] slices from a up to, but not including, b.
- s.upper(), s.lower(); ord() → code, chr() → character.
Key words: string, index, slicing, length, concatenation.
Worked examples
Worked examples from the lesson, with every step.
Question 1
s = "COMPUTER". What is len(s), s[0] and s[3]?
- Step 1: 8 characters
- Step 2: s[0] = C; s[3] = P
Answer: 8, C, P
Question 2
s = "COMPUTER". What is s[1:4]?
- Step 1: 1, 2, 3 (not 4)
- Step 2: O, M, P
Answer: OMP
Question 3
What does this output? c:name = "ada lovelace" c:print(name.upper()[0:3])
- Step 1: "ADA LOVELACE"
- Step 2: first 3 characters
Answer: ADA