Applications of String lower() method
Let’s look at some other uses of the string lower() method in Python. It can be used in other ways, depending on your creativity. We have mentioned one such use of the Python lower() method.
Comparison of Strings using lower() Method
One of the common applications of the lower() method is to check if the two strings are the same or not. In this example, the code compares two strings, `text1` and `text2`, after converting them to lowercase using the `lower()` method. If the lowercase versions of the strings are equal, it prints “Strings are same”; otherwise, it prints “Strings are not same.”
Python3
text1 = 'GEeKS foR GeeKs' text2 = 'gEeKS fOR GeeKs' # Comparison of strings using # lower() method if (text1.lower() = = text2.lower()): print ( "Strings are same" ) else : print ( "Strings are not same" ) |
Output:
Strings are same
We have discussed how to use the lower() method to convert a string to lowercase and also discussed some other ways to perform the same task. The techniques are explained through a program as an example for a better understanding of methods.
You can also check other string methods
Read more related content on the Python Lower Method:
Python String lower() Method
Python string lower() method converts all letters of a string to lowercase. If no uppercase characters exist, it returns the original string.
Example:
Python3
string = "ConvErT ALL tO LoWErCASe" print (string.lower()) |
Output
convert all to lowercase