Python String lower()

Python String lower()

The string lower() method converts all uppercase characters in a string into lowercase characters and returns it.

The syntax of lower() method is:

string.lower()

String lower() Parameters()

lower() method doesn't take any parameters.


Return value from String lower()

lower() method returns the lowercased string from the given string. It converts all uppercase characters to lowercase.

If no uppercase characters exist, it returns the original string.


Example 1: Convert a string to lowercase

# example string
string = "THIS SHOULD BE LOWERCASE!"
print(string.lower())

# string with numbers
# all alphabets whould be lowercase
string = "Th!s Sh0uLd B3 L0w3rCas3!"
print(string.lower())

Output

this should be lowercase!
th!s sh0uld b3 l0w3rcas3!

Example 2: How lower() is used in a program?

# first string
firstString = "PYTHON IS AWESOME!"

# second string
secondString = "PyThOn Is AwEsOmE!"

if(firstString.lower() == secondString.lower()):
    print("The strings are same.")
else:
    print("The strings are not same.")

Output

The strings are same.

Note: If you want to convert to uppercase string, use upper(). You can also use swapcase() to swap between lowercase to uppercase.