← All lessons

upper and lower

Sign in · Sign up

Lesson 4.3

String methods are called with a dot:

print("python".upper())    # PYTHON
print("Python".lower())    # python
print("mia".capitalize())  # Mia

A method does not change the string — it returns a new one. That's why the result is saved in a variable or printed right away:

name = "mia"
name.upper()
print(name)   # mia — nothing changed

The word is set by the check. Print it three times in order: all uppercase, all lowercase, and with a capital first letter.

Hint

.upper() makes everything uppercase, .lower() makes it lowercase.

title() capitalises every letter after a space and a hyphen. Each method returns a new string — print that one.