The lower()
method in Python is a string method that returns a copy of the string with all alphabetic characters converted to lowercase. It does not modify the original string, but instead returns a new string with all lowercase characters.
Parameter Values
This function does not accept any parameters.Return Values
The lower()
method returns a new string with all uppercase characters converted to lowercase.
How to Use lower()
in Python
Example 1:
The lower()
method returns a copy of the string in which all case-based characters have been converted to lowercase.
string = 'Hello, World!'
lower_string = string.lower()
print(lower_string) # Output: hello, world!
Example 2:
It does not modify the original string, but returns a new string with all lowercase characters.
text = 'PYTHON IS FUN'
lower_text = text.lower()
print(lower_text) # Output: python is fun
Example 3:
The lower()
method is useful for case-insensitive comparisons and data processing.
word = 'HELLO'
if word.lower() == 'hello':
print('Words match')
else:
print('Words do not match') # Output: Words match