The Python lower function converts all uppercase characters in the given string into lowercase letters and returns a new string. It keeps the lowercase characters unchanged. For instance, Hi.lower() converts H to h, leaves i unchanged, and returns hi as the output.
The lower() function is very helpful in data normalization, user input validation, string comparison, authentication systems, etc. Let us see how to convert a string to lowercase with an example.
Python lower() syntax
The syntax of the string lower() function is as shown below.
String_Value.lower()
Here, string_value is the original string.
Parameters: The string lower() does not accept any parameters.
Return Value: The lower() method converts all uppercase characters in the original string to lowercase and returns a new string. If the original string does not have uppercase letters, it returns the original text as the output.
Python lower function Example
The following set of lower function examples helps to understand how to convert a string to lowercase using the lower() function. In this Python example, first, we declared a variable. The second statement converts the variable Str1 into lowercase and prints the output.
The lower function only converts the letters into lowercase and leaves other values unchanged. Within the following statements, we used the lower() function on a string with a combination of numeric values and letters (alphabets).
TIP: It keeps the Non-letters unchanged.
Str1 = 'Learn PYTHON AT Tutorial GateWay'
Str2 = Str1.lower()
print('First Output of a method is = ', Str2)
# Observe the Original
print('ConvertedString is = ', Str1.lower())
print('OriginalString is = ', Str1)
# Performing it directly
Str3 = 'PYTHON ProGramming'.lower()
print('Second Output of a method is = ', Str3)
Str4 = 'PYTHON1234Tutorial'.lower()
print('Third Output of a method is = ', Str4)
Str5 = '12345'.lower()
print('Third Output of a method is = ', Str5)

Does lower() function modify the original string?
No. The lower() function example code returns the output in a new string. To change the original, write the following statement (Str1 = Str1.lower()).
text = "HI"
text.lower()
print(text)
text = text.lower()
print(text)
HI
hi
Python lower() function to compare strings
When performing the string comparisons, we must use the lower() or upper() functions to convert the existing string to lowercase or uppercase. To capitalize the first character, use the capitalize() function.
In the example below, both strings have a combination of upper and lowercase characters. When you compare both (if a == b), it returns false. However, if we use the lower() function on both, it becomes true.
a = "HeLLo"
b = "hELlO"
if a.lower() == b.lower():
print("a equals b")
else:
print("a not equals b")
a equals b
Normalize email address
mail = "CONTACT@EXAMPLE.COM"
m = mail.lower()
print(m)
contact@example.com
Using the Python lower() function on Lists and Loop
In the following example, each fruit in a list has mixed-case characters. Here, the list comprehension with a for loop iterates over the list items and converts each list of strings to lowercase.
fruits = ["AppLE", "ORANGE", "KiWi", "MaNgo"]
res = [fr.lower() for fr in fruits]
print(res)
[‘apple’, ‘orange’, ‘kiwi’, ‘mango’]
Searching in a CSV file
The if statement with the IN operator searches for the required word inside a list of keywords. Here, the lower() function converts the search word to lowercase to maintain uniformity.
keywords = ["seo", "meta", "tutorial", "title"]
word = "SEO"
if word.lower() in keywords:
print("Keyword found")
Keyword found
Difference between lower() and casefold()
Both will convert the uppercase characters in an original string to lowercase characters. However,
- lower() is the standard option for regular characters.
- casefold() recognizes the Unicode characters and is good for international applications.