Returns a copy of a string in lowercase.
Synopsis
text.lower()
Description
Use lower to compare answers without caring about capitals.
It is a method: a function that belongs to the string, called with a dot. It does not change the original string. It returns a new one.
Return value
A new str.
Example
answer = input("Do you agree? ").lower()
if answer in ["y", "yes"]:
print("Agreed.")
It prints:
Do you agree? YES
Agreed.
Common mistake
word = "HELLO"
word.lower()
print(word)
It prints:
HELLO
Strings never change. Keep the result: word = word.lower().
See also
Last updated 2 weeks ago