In Python, lower() is a built-in method that returns the lowercased string from the given string. It transforms the characters in the upper case into lowercase.
If there are no uppercase characters, it returns the original string. Symbols and Numbers are ignored.
The syntax of the method is: str.lower()
Key Points :
• Return Type: The lower() method returns the lowercase string of the string defined. It converts all characters in the upper case to lower case.
• Parametric values: No parameters are taken into the lower() function.
• Because strings in Python are immutable, only a copy of the original string is returned.
• If there are no uppercase characters, the original string will be restored.
Below is the python program to demonstrate the lower() function:
str = "THE BEST LEARNING RESOURCE FOR ONLINE EDUCATION"; print (str.lower())
When we run above the program, the outcome is as follows:
the best learning resource for online education
We’ll be covering the following topics in this tutorial:
Python String lower(): Digits and Symbols
If any string consists of numbers, symbols, and letters, then the numbers and symbols are restored, while the letters are translated into lowercase. Let’s see the following snippet code:
str = "LUCKY786" print(str.lower())
When we run above the program, the outcome is as follows:
lucky786
Python String lower(): To check if two string are same or not
# first string Str_first = "THE BEST LEARNING RESOURCE FOR ONLINE EDUCATION" # second string Str_Second = "The Best Learning Resource for ONLINE EDUCATION" if(Str_first.lower() == Str_Second.lower()): print("Both Strings are Same.") else: print("Both Strings are not Same.")
When we run above the program, the outcome is as follows:
Both Strings are Same.
Note: Use upper() if you choose to switch to uppercase. You may also use swapcase() to swap between lowercase to uppercase.
Below are several other functions that we can use to work with string in Python 3