Python String lower() Method
The Python lower() method converts all uppercase characters in a string to lowercase.
Python String lower() Syntax
lower() method syntax.
str.lower()
Python String lower() Parameters
- None.
Python String lower() Return Value
Returns the string generated by converting all uppercase characters in the string to lowercase.
Python String lower() Example#1
The lower() function is used to convert characters, and the following is a string with only alphabetic characters.
#!/usr/bin/python3
text = 'Api Demos'
print("Original String:")
print(text)
# lower() function to convert string to lower_case
print("\nConverted String:")
print(text.lower())
Output:
Python String lower() Example#2
The lower() function converts a string to lowercase letters, and below is the string with alphanumeric characters.
#!/usr/bin/python3
text = 'A1p2i D3em4os'
print("Original String:")
print(text)
# lower() function to convert string to lower_case
print("\nConverted String:")
print(text.lower())
Output:
Python String lower() Example#3
Compare strings using the lower() method. One of the common applications of the lower() method is to check whether two strings are identical.
#!/usr/bin/python3
text1 = 'api demos'
text2 = 'APi DEMos'
# Comparison of strings using lower() method
if(text1.lower() == text2.lower()):
print("Strings are same")
else:
print("Strings are not same")
Output: