Python String upper() method
Python String upper() method
The string.upper() method in Python returns a copy of the string converted to uppercase.
Syntax
string.upper()
Parameter
NA
Return
This method returns a copy of the string converted to uppercase.
Example 1
# Python program explaining
# the string.upper() method
# initializing the string
string= "hello world"
print("Actual String",string)
# converting to uppercase
print("Uppercase...",string.upper())
string="My name is reema."
print("Actual String",string)
# converting to uppercase
print("Uppercase...",string.upper())
Output
Actual String hello world Uppercase... HELLO WORLD Actual String My name is reema. Uppercase... MY NAME IS REEMA.
Example 2
# Python program explaining
# the string.upper() method
# first string
String1 = "python is easy To learn!"
# second string
String2 = "PyThOn Is eAsY To leArn!"
# comparing both the strings
if(String1.upper() == String2.upper()):
print("Both the strings are same.")
else:
print("Both the strings are not same.")
Output
Both the strings are same.
