English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The lower() method of the string converts all uppercase letters in the string to lowercase and returns them.
The syntax of the lower() method is:
string.lower()
The lower() method does not take any parameters.
The lower() method returns the lowercase string from the given string. It converts all uppercase letters to lowercase.
If there are no uppercase letters, return the original string.
# Example string string = "THIS SHOULD BE LOWERCASE!" print(string.lower()) # String and number # All letters are lowercase string = "Th!s Sh0uLd B3 L0w3rCas3!" print(string.lower())
When running the program, the output is:
this should be lowercase! th!s sh0uld b3 l0w3rcas3!
# First string firstString = "PYTHON IS AWESOME!" # Second string secondString = "PyThOn Is AwEsOmE!" if(firstString.lower() == secondString.lower()): print("The strings are the same.") else: print("The strings are different.")
When running the program, the output is:
The strings are the same.
Note:If you want to convert it to an uppercase string, please useupper()You can also useswapcase()Swap lowercase and uppercase letters.