python String lower() Method
The lower() function is a built-in function that is mainly used to manipulate strings. Converts text strings written in lowercase letters to uppercase letters. If there are no uppercase letters in the specified string, it returns the original string.
How to formulate it like this:
string.lower()
Argument: The lower() function takes no argument.
return value: The lower() function returns a new string with lowercase letters than the original string
مثال:
txt = "LEARN PYTHON WITH AHMED OBAID"
print(txt.lower())
The output will be:
learn python with ahmed obaid
The following example shows how to display the original string and the converted string to uppercase via the lower() function
Example:
txt = 'LEARN PYTHON WITH AHMED OBAID'
print("Original String:")
print(txt)
# lower() function to convert
# string to lower_case
print("Converted String:")
print(txt.lower())
The output will be:
Original String:
LEARN PYTHON WITH AHMED OBAID
Converted String:
learn python with ahmed obaid
The lower() function can also be used to check whether two strings are the same
a = 'learn python with ahmed obaid'
b = 'Learn Python with Ahmed Obaid'
# Comparison of strings using
# upper() method
if (a.lower() == b.lower()):
print("Strings are same")
else:
print("Strings are not same")
The output will be:
Strings are same
External sources:
Built-in functions - official Python documentation
If you have any questions or concerns, leave them in the comments
Tags
Python Python String string methods python python string lower method
Share page
About author
Ahmed Obaid
Hello, I am Ahmed Obaid, an Egyptian Arabic programmer. I would like to put my experiences learning Python on this site So that it will be a reference for you and me as well.
Sign up to leave a comment