StudyDeck

String Handling

Exam code: 2210
Written by: Ashika|Reviewed by: Caroline Carroll|Updated 2 July 2026

String Handling

String Handling

What is string manipulation?

  • String manipulation is the use of programming techniques to modify, analyse or extract information from a string

  • Examples of string manipulation include:

    • Case conversion (modify)

    • Length (analyse)

    • Substrings (extract)

Case conversion

  • The ability to change a string from one case to another, for example, lower case to upper case

Function

Pseudocode

Python

Output

Uppercase

Name ← "Sarah"
OUTPUT UCASE(Name)
Name = "Sarah"
print(Name.upper())

"SARAH"

Lowercase

Name ← "SARAH"
OUTPUT LCASE(Name)
Name = "SARAH"
print(Name.lower())

"sarah"

Length

  • The ability to count the number of characters in a string, for example, checking a password meets the minimum requirement of 8 characters

Pseudocode

Python

Output

Password ← "letmein"
OUTPUT LENGTH(Password)
Password = "letmein"
print(len(Password))

7

Password ← "letmein"
IF LENGTH(Password) >= 8
    THEN
        OUTPUT "Password accepted"
    ELSE
        OUTPUT "Password too short"
ENDIF
Password = "letmein"
if len(Password) >= 8:
    print("Password accepted")
else:
    print("Password too short")

"Password too short"

Substring

  • The ability to extract a sequence of characters from a larger string in order to be used by another function in the program, for example, data validation or combining it with other strings

  • Extracting substrings is done by specifying a start position and length in pseudocode, or a start and end index in Python.

  • Substring has a start position of 1 in pseudocode and 0 in Python

Pseudocode

Python

Output

Word ← "Revision"
OUTPUT SUBSTRING(Word, 1, 3)
Word = "Revision"
print(Word[0:2])

"Rev"

Word ← "Revision"
OUTPUT SUBSTRING(Word, 3, 6)
Word = "Revision" 
print(Word[2:5])

"vision"