How to convert all characters of a string to uppercase in Python

Conversion of String Characters to Uppercase in Python

In Python, you can convert all charcters of a string to uppercase using the str.upper() method.

Converting all characters of a string to uppercase using 'str.upper()' method

1. Create a variable named str_variable and assign string value "python is a programming language." to the variable.

2. Apply the upper() method to the string variable str_variable. This method converts all characters of the string to uppercase. Store the result in a new variable called upper_string.

Please take a closer look at the following example:

Example of using upper() method

Output of the above example
PYTHON IS A PROGRAMMING LANGUAGE.

Live Code Playground

In the following Python code editor, you can practice the above code by creating more string variables and converting their characters to uppercase using upper method. Click on the 'Execute Code' button to execute the code; the executed output will be displayed in the following Python Code Output frame. Practice until you become comfortable and proficient with your code.

Python logo Python Online Editor
Python Code Output