Python String upper() Method Tutorial

In this section, we will learn what String upper() method is and how to use it in Python.

Python String Uppercase with upper() Method

The Python string upper() method is used to create the uppercase characters of a string value and return that as a result.

Note that this method does not change the original string value that this method is called upon. Instead, the method returns its own copy of that string with each character set to uppercase.

Python String upper() Method Syntax:

string.upper()

String upper() Method Parameter

The method does not take an argument.

String upper() Method Return Value

The return value of this method is a new string that contains the entire characters of the target string value all set to uppercase.

This means the original string value (the one that this method is called upon) won’t change.

Example: convert to uppercase

s1 = "They know we know that they know we know!"

result = s1.upper()

print(result)

Output:

THEY KNOW WE KNOW THAT THEY KNOW WE KNOW!

Example: python string to uppercase

s1 = "Hello World 123!"

result = s1.upper()

print(result)

Output:

HELLO WORLD 123!
Facebook
Twitter
Pinterest
LinkedIn

Top Technologies