python String lower() Method

28-12-22 Ahmed Obaid 1168 0

​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