Student Handbook

Student Handbook

Open in ChatGPT
Ask ChatGPT about this page
Open in Claude
Ask Claude about this page

str.lower

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

str.upper, in, str.strip

str.lower in the Python documentation

Last updated 2 weeks ago