Skip to content
Tutorials Center
My learning

Topics

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".

Python
print("Hello, WORLD!".lower())   # hello, world!

Try it

Python Normalizing input

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.

Python Unicode and comparisons

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

Python
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, i plus a combining dot.
  • Use casefold() for caseless matching. casefold() is stronger: it turns "ß" into "ss", so "Straße" matches "STRASSE", while lower() leaves ß alone.
  • Locale independent. lower() does not use the current locale, so it behaves the same on every machine. Turkish-style rules (I to ı) 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() == s is similar but not identical when s has no letters.