Python lower
Python String lower Method
The Python lower function generates a new string in which all the characters have been transformed to lowercase.
Syntax of Python String lower Method
It has the following syntax:
Example
lower()
Parameters
No parameter.
Return
It returns a lowercase string.
Different Examples for Python String lower Method
Let's examine a few examples of the lower method to gain a clearer understanding of its capabilities.
Example 1
Here is a straightforward illustration demonstrating the process of transforming a string into its lowercase equivalent.
Example
# Python lower() method example
# Variable declaration
str = "Example"
# Calling function
str = str.lower()
# Displaying result
print(str)
Output:
Output
logicpractice
Example 2
A string can vary in its composition and may contain letters in any case. This method will produce and return a new string that is entirely in lowercase.
Example
# Python lower() method example
# Variable declaration
str = "Welcome To HELLOworldvisualizer, WWW.logic-practice.com"
# Calling function
str = str.lower()
# Displaying result
print(str)
Output:
Output
welcome to logicpractice, www.logic-practice.com
Example 3
We can verify if it returns lowercase by employing an if statement. Refer to the example provided below.
Example
# Python lower() method example
# Variable declaration
str = "LOGICPRACTICE"
# Calling function
if str.lower() == "logicpractice":
print("lowercase")
else:
print("not lowercase")
Output:
Output
lowercase