Python String upper() Method: Converting a String to Uppercase (original) (raw)
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()Code language: Python (python)
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.
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)`Code language: Python (python)
Output:
python uppercase PYTHON UPPERCASECode language: Python (python)
Summary #
- Use the Python string
upper()method to return a copy of a string with all characters converted to uppercase.
Was this tutorial helpful ?