Python Reference · String Methods
Python str.lower() method
Reference for Python str.lower(): convert a string to lower case, why it returns a new string, Unicode edge cases, and when casefold() is better for comparisons.
The lower() method returns a copy of the string with every cased character converted to lower case. Characters without a lower-case form, such as digits and punctuation, stay as they are. The original string is not modified, because strings are immutable.
A typical use is normalizing user input before comparing it: "Yes", "YES" and "yes" all become "yes".
print("Hello, WORLD!".lower()) # hello, world!
Try it
Press Run (or Ctrl + Enter) to see the result here.
Program input · what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.
Press Run (or Ctrl + Enter) to see the result here.
Program input · what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.
Syntax
str.lower()
This method takes no parameters.
Return value: a new string in lower case. If nothing changes, CPython may return the same object, so never rely on identity.
Raises: nothing.
Usage notes
- Returns a copy. Writing
name.lower()alone does nothing useful; assign the result:name = name.lower(). - Unicode aware. Accented and non-Latin letters with case are converted. Final-sigma handling follows the Unicode rules, so
"ΣΑΣ".lower()ends withς. - Length can change.
"İ".lower()(capital I with a dot) becomes two code points,iplus a combining dot. - Use
casefold()for caseless matching.casefold()is stronger: it turns"ß"into"ss", so"Straße"matches"STRASSE", whilelower()leavesßalone. - Locale independent.
lower()does not use the current locale, so it behaves the same on every machine. Turkish-style rules (Itoı) need special handling. - Dictionary keys and sets. Lower-casing keys before storing them is a common way to get case-insensitive lookups.
- Bytes.
bytes.lower()only changes ASCII letters. - Check without converting.
s.islower()tests;s.lower() == sis similar but not identical whenshas no letters.