Junior Codes
Message Harbour

Python String Methods for Kids

Clean up and reshape text with upper(), lower(), strip() and more.

Start Wonderwild free with Pip

Try 5 starter activities free. Full access is ₹499 a year.

This mission is part of full access. The first missions are free to try.

String methods, explained simply

Text in Python comes with built-in tools called methods. You use one by writing a dot after the text (or a variable holding it), then the method name and brackets.

upper() makes every letter a capital, and lower() makes every letter small. strip() removes extra spaces from the start and end, which is handy when people type a space by accident. replace() swaps one piece of text for another.

Methods give back a new string. The original stays the same unless you store the result, for example word = word.strip().

Example: Tidy up a password

typed = "  OpenSesame  "
clean = typed.strip().lower()
print(clean)
print(clean.replace("sesame", "sky"))

Output

opensesame
opensky

replace() found "sesame" inside the word and swapped it for "sky".

Try this

  • Shout a message by printing it with upper().
  • Ask for a yes or no answer and use lower() so "YES", "Yes" and "yes" all count.
  • Use replace() to turn every "a" in a sentence into "@".

Practise it in Wonderwild

“Repair the secret password”

Mission 10 in Message Harbour, one of 36 Python missions in Wonderwild.

Your child writes and runs real Python in the browser while Pip reacts to every line. Nothing to install. For ages 7+.

Start Wonderwild free with Pip

Try 5 starter activities free. Full access is ₹499 a year.

This mission is part of full access. The first missions are free to try.

Questions parents and kids ask

Why does my string not change after calling a method?+

Strings in Python cannot be changed in place. Methods return a new string, so you need to store it, for example name = name.upper().

What is the difference between a function and a method?+

A function stands on its own, like len(word). A method belongs to a value and is written after a dot, like word.upper().

Prefer learning with a teacher?

Our live Python for Young Developers course teaches these ideas in small online classes led by a software engineer, with projects and feedback. Every live course also includes 12 months of full Wonderwild access for practice.

See the Python for Young Developers course