Python String upper()

Created with Sketch.

Python String upper()

Summary: in this tutorial, you’ll learn how to use the Python String upper() method to return a copy of a string with all characters converted to uppercase.

Introduction to the Python String upper() method

The upper() is a string method that allows you to return a copy of a string with all characters converted to uppercase.

The following shows the syntax of the upper() method:

str.upper()

 

The upper() method takes no argument.

Note that the upper() method doesn’t change the original string.

To return a copy of a string with all characters converted to lowercase, you use the str.lower() method.

Python String upper() method example

The following example uses the upper() method to return a copy of a string with all characters converted to uppercase:

s = 'python uppercase'
new_s = s.upper()
print(s)
print(new_s)

 

Output:

python uppercase
PYTHON UPPERCASE

 

Summary

  • Use the Python string upper() method to return a copy of a string with all characters converted to uppercase.

Leave a Reply

Your email address will not be published. Required fields are marked *