The lower
method in Python will convert all the characters of a string to lowercase.
string_A.lower()
The function takes in no parameter.
The function returns a new string which is created from string_A
by converting all the characters of string_A
into lowercase.
If there are no uppercase characters in
string_A
, then the original string is returned.
string_A = "EduCaTIVE"print(string_A, " lower() -> ", string_A.lower())
In the code above, we have created an EduCaTIVE
string and called the lower
method which will convert all the characters of the string to lowercase.
string_A = "Educative"string_B = "EDUCATIVE"print("String_A = ", string_A)print("String_B = ", string_B)print("String_A == String_B ", string_A == string_B)print("String_A.lower() == String_B.lower() ", string_A.lower() == string_B.lower())
In the code above, we have created two strings, Educative
and EDUCATTIVE
. When we compare the two strings, we will get False
because the cases of the two strings are different.
We then used the lower
method to convert both strings to lowercase. After both strings are converted to lowercase, we will get True
when we check whether the two strings are the same.