Revise Computing
Revision notesQuestionsFor schools
Log inStart revising free
Revision notesQuestionsFor schoolsLog in
GCSE Computer Science/Supplementary programming practice/String Manipulation

String length

301.11 String Manipulation

Practise exam questions

String Manipulation — Note 1 of 4

Measure size of string.

What you need to know

len() returns the number of characters in a string, including spaces and punctuation. It is commonly used for validation and loop control.

What to know

  • len("hello") → 5
  • Spaces count: len("hi there") → 8
  • Empty string: len("") → 0
  • Useful for checking minimum/maximum lengths

Code examples

String length
python
name = input("Username: ")
if len(name) < 3:
    print("Too short — at least 3 characters")
else:
    print("Welcome, " + name)
← Previous topicLoop bugs301.10 IterationNext note →Substring slicing301.11 String Manipulation

Back to String Manipulation

Specification notes for programming are in Paper 2.

String Manipulation

Note 1 of 4

  1. 1String length
  2. 2Substring slicing
  3. 3Case conversion
  4. 4String validation
Topic overview

© 2026 Revise Computing · revisecomputing.co.uk

Privacy noticeTermsContact

Revise Computing is an independent revision resource. It is not affiliated with, or endorsed by, OCR (Oxford Cambridge and RSA Examinations).