Manipulating strings
Usernames, passwords and messages are all strings. Python gives you tools to measure, slice and change them.
Length and position
Characters are numbered from 0. If word = "Python", word[0] is "P" and word[5] is "n".
word[-1] is the last character.
word.find("h") gives the position of the first "h": 3. It gives -1 if not found.
Substrings (slicing)
"Python"[0:3] is "Pyt". "Python"[2:] is "thon".
Case conversion and joining
Compare in one case so "YES", "Yes" and "yes" are all accepted: if answer.lower() == "yes":
Join strings with +: "Py" + "thon" gives "Python".
Make a username from the first 3 letters of "Amelia" and her birth year 2010.
- "Amelia"[0:3] = "Ame"
- str(2010) = "2010"
- Join with +
Answer: Ame2010
len() counts characters. Positions start at 0. word[a:b] gives a substring up to but not including b. upper() and lower() change case; + joins strings.
- Not βanswer.upper() == "yes"β. upper() gives "YES", which does not equal "yes".
Try two quick questions
See if it has sunk in. Answers are marked straight away.
2 more questions
Try each one, then tap to check.
What does len("Algorithm") return?
Show the answer
Answer: 9
A-l-g-o-r-i-t-h-m has 9 characters.
word = "Server". What is word[0]?
Show the answer
Answer: S
Indexes start at 0, so word[0] is the first character, S.
Check you have got it
Answer 6 quick questions with instant marking. If you get one wrong, GCSE-ready shows you why and gives you another go. It is free, and you do not need an account.
- Pearson Edexcel GCSE Computer Science (1CP2) specification, topic 6.3.3
- Pearson Edexcel International GCSE Computer Science (4CP0) specification, topic 2.3.3
Facts checked against the sources below, 17 October 2026. Last updated 2 October 2026. Spotted a mistake? Tell us and we will fix it.
What do exam command words like explain and evaluate mean? β