The upper() function in python helps to return a copy of the original string, in which all the lowercase characters of the string are converted into uppercase. If no lowercase letters, it will return the original string.
string.upper()
The upper() method doesn't take any parameters. At the time of conversion, all symbols and letters are ignored.
The return value is always a string. This method is similar to capitalize() method, the difference is that capitalize() convert only the first letter of the word into uppercase whereas upper() converts all characters of the string into uppercase.
Input | Return Value |
---|---|
string | uppercased string |
# example string
string = "How are you?"
print(string.upper())
# string with numbers
string = "Hii! How Are You123?"
print(string.lower())
Output:
HOW ARE YOU? HII! HOW ARE YOU123?
# first string
String1 = "ProgRammIng LanGuaGe!"
# second string
String2 = "programming language!"
if(String1.upper() == String2.upper()):
print("The two strings are same.")
else:
print("The two strings are not same.")
Output:
The two strings are same.