Python String upper() Method

Converts all characters in a string to uppercase

Usage

The upper() method returns a copy of the string with all the characters converted to uppercase. This method does not change the original string.

Syntax

string.upper()

Examples

# Convert all characters to uppercase
S = 'Hello, World!'
x = S.upper()
print(x)
# Prints HELLO, WORLD!

upper() method ignores numbers and special characters in a string.

S = '123 abc [email protected]%'
x = S.upper()
print(x)
# Prints 123 ABC [email protected]%