Understanding Python String lower()
Python String lower()
In Python, String lower() is an inbuilt string handling function.
- String
lower()method is used to return a copy of a specified string where all case-based characters turned into Lowercase. - The main aim of this function is to convert the string into Lowercase.
Python String **lower()**: Syntax
Below we have a basic syntax of String lower() in Python:
string.lower()Python String **lower()**: Parameters
From the above syntax, it is clear that this function does not take any parameters.
- If we pass any parameter to this function then it will raise an error.
Python String **lower()**: Basic Example
Below we have an example to show the working of String lower() function:
str="One wOMan"
print(str.lower())The output for the same is given below:
one woman
Python String **lower()**: Digits and Symbols
If any string comprises digits, symbols, and letters; in that case, digits and symbols will be returned as it is while letters will be converted into Lowercase. Let us see the code snippet given below:
str1="123!!WoMaN"
print(str1.lower())The Output will be:
123!!woman
Python String **lower()**: To check if two string are same or not
In the example given below, we will check if the two given strings are equal or not with the help of lower() method. Let us see the code snippet given:
# working of lower() function
string1 = 'Welcome To StudyTonight'
string2 = 'weLcoMe to studyTONIGHT'
if(string1.lower() == string2.lower()):
print("string1 and string2 are same")
else:
print("String1 and string2 are not same") The Output will be:
string1 and string2 are same
Summary
In this tutorial, we saw how to convert all case-based characters of a string into a lowercase using String lower() method of Python, we had also applied this method on digits and symbols to see the impact of this method on digits and symbols. We had also used Live Example for the same.










