Learning LibraryCore Coding LibraryKids

String methods: change text with built-in helpers

Text comes with built-in helpers. Add a dot and a helper's name after a string, and you can shout it, tidy it, or trim off extra spaces.

The big idea

A string method like .upper() is a built-in helper that gives you back a changed version of the text.

See it in code

1Start simple

Add a dot and a helper's name after a string. Our hero's name is stored in lowercase, and .upper() shouts it in capitals:

python
name = "blaze"
print(name.upper())
Run it — the name, in all caps:
BLAZE

One dot, one helper, and blaze came back as BLAZE.

2A step further

A helper hands back a new string and leaves the first one alone. .capitalize() makes just the first letter big — but name itself doesn't change:

python
name = "blaze"
print(name.capitalize())
print(name)
Run it — a tidy copy, then the untouched original:
Blaze
blaze

See it? .capitalize() gave Blaze, but name is still blaze. The helper makes a new word — it doesn't rewrite yours.

3In our world

Now all together. .upper() shouts, .capitalize() tidies the first letter, and .strip() trims spare spaces off the ends of any text:

python
name = "blaze"

print(name.upper())
print(name.capitalize())
print("  hi  ".strip())
Run it — three helpers, three tidy results:
BLAZE
Blaze
hi

"blaze".upper() gave BLAZE, and .capitalize() gave Blaze. Just like the warm-up, the helper hands back a new string — your original name is still "blaze" unless you save the result.

The same idea, everywhere

String helpers tidy text everywhere. Make a title shout, clean up messy player input, or check if a word ends in a certain letter. Text is one of the most common things code handles, and these helpers do the heavy lifting.

Try it yourself

Try name.replace("z", "Z") to swap a letter. Then print len(name) to count the letters, and "HELLO".lower() to quiet a shout down.

The common mistake

Expecting the original to change. name.upper() does not change name — it hands back a new string. To keep the capitals, save them: loud = name.upper().

What it unlocks

String helpers build on data types, dress up f-strings, and clean up answers from input().

Older, or want more depth? Read the Teens version →