Python Reference Library →

Python String upper() Method – Convert to Uppercase

Let’s look at string upper() method – convert to uppercase

  1. Notice

    upper() returns a Unicode uppercase version. Some characters can expand into more than one character.

  2. Try

    Follow the example, change its sample, and compare what happens.

  3. Check

    Explain the result and test your understanding.

Watch how it works

Focus on how the names, objects, and calculations change. We’ll inspect the printed output in the next section.

Explore the idea

Follow the code and watch its state change. Guided simulation.

Code
Python
text = 'tea'
result = text.upper()
print(result)
Live state

Top-level scope

text→Object 1
result→Object 2
Object 1 · str'tea'Object 2 · str'TEA'
This step

upper() returns a Unicode uppercase version. Some characters can expand into more than one character.

Picture string upper() method – convert to uppercase

upper() returns a Unicode uppercase version. Some characters can expand into more than one character.

Image brief

Alt text
A diagram for Python String upper() Method – Convert to Uppercase. Instructions: text = 'tea' result = text.upper() print(result). Displayed result: TEA. The final example bindings are text --> object 1 (str); result --> object 2 (str). object 1: 'tea'; object 2: 'TEA'
Image generation prompt
Create a clean educational illustration for a Python programming lesson titled "Python String upper() Method – Convert to Uppercase". Teaching focus: upper() returns a Unicode uppercase version. Some characters can expand into more than one character. Depict exactly the relationships and labels in this reference diagram: EXAMPLE INSTRUCTIONS text = 'tea' result = text.upper() print(result) | v DISPLAYED RESULT TEA FINAL BINDINGS text --> object 1 (str) result --> object 2 (str) object 1: 'tea' object 2: 'TEA' Use a flat vector style, generous spacing, clear arrows and legible labels, with a restrained blue/teal palette on a plain background. The diagram must explain the programming idea accurately. Do not depict variables as boxes containing copied objects when they share a reference. Avoid mascots, decorative screenshots, logos, gradients and extra text. Landscape composition, approximately 3:2, suitable for a course card. Accessible description: A diagram for Python String upper() Method – Convert to Uppercase. Instructions: text = 'tea' result = text.upper() print(result). Displayed result: TEA. The final example bindings are text --> object 1 (str); result --> object 2 (str). object 1: 'tea'; object 2: 'TEA'

Follow the execution

Choose a different sample input, then follow every step through to the output. Before revealing it, predict what the program will display.

Execution workspace

Choose a sample and follow its execution. Guided simulation.

Code
Python
text = 'tea'
result = text.upper()
print(result)
Live state

Top-level scope

text→Object 1
result→Object 2
Object 1 · str'tea'Object 2 · str'TEA'
This step

The example has finished. Compare the final output with the values and references above.

Terminal
Output
TEA

What do you expect this program to print?

What does this example display?

text = 'tea'
result = text.upper()
print(result)
What does this example display?
Choose one answer. You can try again.

Answer and explanation

TEA

Follow the printed values in order. The output is: TEA

Which explanation matches what you learned?

Which explanation matches what you learned?
Choose one answer. You can try again.

Answer and explanation

upper() returns a Unicode uppercase version. Some characters can expand into more than one character.

upper() returns a Unicode uppercase version. Some characters can expand into more than one character.

More examples and reference

Python String upper() Method

The upper() method in Python converts all lowercase characters in a string to uppercase. It is a built-in string method and is very useful when you want to standardize or compare text.

Syntax

string.upper()

Parameters:

  • This method takes no parameters.

Returns:

  • A new string with all characters in uppercase.

Example 1: Basic Usage

text = "hello world"
print(text.upper())
HELLO WORLD

Example 2: Mixed Case String

name = "Alice123"
print(name.upper())
ALICE123

Note: Numbers and symbols remain unchanged.

Use Cases

  • To standardize user input (e.g., emails, usernames)
  • For case-insensitive string comparisons
  • To make output visually distinct (e.g., titles, warnings)

Does it change the original string?

No. Strings in Python are immutable. upper() returns a new string — it does not modify the original.

word = "python"
new_word = word.upper()
print(word)      # python
print(new_word)  # PYTHON

Common Mistakes

  • Trying to use upper without parentheses – remember it’s a method: string.upper()
  • Assuming it changes the original string – you must assign the result if needed

Interview Tip

In coding tests, upper() is handy for making string comparisons or normalizing data without worrying about the input case.

Summary

  • upper() converts all characters in a string to uppercase.
  • Does not affect numbers or special characters.
  • Returns a new string – original remains unchanged.

Practice Problem

Write a program that asks the user to enter their name and prints it in all capital letters.

name = input("Enter your name: ")
print("Your name in uppercase is:", name.upper())

What to remember

Connect what you noticed in the example with the idea below.

Remember

upper() returns a Unicode uppercase version. Some characters can expand into more than one character.

Watch out for this idea

upper() always preserves the exact number of characters.

This is the misconception to avoid.

Reference checks are optional and do not count toward course progress.

    Reference library →