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

String validation

301.11 String Manipulation

Practise exam questions

String Manipulation — Note 4 of 4

Check patterns in text.

What you need to know

String methods like .isalpha(), .isdigit(), and .isalnum() check whether a string contains only certain types of characters. They return True or False.

What to know

  • .isalpha() — True if all letters
  • .isdigit() — True if all digits
  • .isalnum() — True if letters or digits only
  • Empty string returns False for all checks
  • Useful for input validation

Code examples

String validation
python
postcode = input("Postcode: ")
if postcode.isalnum() and len(postcode) >= 5:
    print("Valid format")
else:
    print("Invalid postcode")
← Previous noteCase conversion301.11 String ManipulationNext topic →Why subprograms301.12 Subprograms

Back to String Manipulation

Specification notes for programming are in Paper 2.

String Manipulation

Note 4 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).