The Python lower function converts the given string into Lowercase letters and returns a new one. Let us see how to convert a string to lowercase with an example, and the syntax is
Python lower function Example
The following set of examples helps to understand how to convert a string to lowercase using the lower function.
First, we declared a variable. The second statement converts the variable Str1 into lowercase and prints the output.
The function only converts the letters into lowercase and leaves other values unchanged. Within the following statements, we used numeric values along with letters.
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)
This example code returns the output in a new string instead of altering the original. To change the original, write the following statement.
Str1 = Str1.lower()