Convert uppercase to lowercase in Python
Python String lower()
By using the built-in string lower() method, all the uppercase characters can be converted into lowercase characters in a string,
The lowercased string from the given string is returned by the lower() method.
Syntax :
string.lower()
Parameters:
It does not need any parameters.
Returns :
All the uppercase characters are converted into lowercase and, the lowercase string is returned.
Example 1:
string = "THIS IS JAVATPOINT"
print(string.lower())
# string with numbers
string = "Th!s I0 JAVA8POin8t!"
print(string.lower())
Output:
this is javatpoint
th!s i0 java8poin8t!
Example 2:
Using lower() in the Program
firstString = "TUTORIAL AND EXAMPLES!"
# second string
secondString = "TUtOrIaL AnD EXaMPlEs!"
if(firstString.lower() == secondString.lower()):
print("The strings are same.")
else:
print("The strings are not same.")
Output:
The strings are same.
Errors And Exceptions
- There is no need to pass the parameter because it doesn't take any arguments. Hence, it returns an error.
- Only the uppercase characters are converted to lowercase but the symbols and numbers are returned as it is.