Skip to main content

How to Make a String Lowercase in Python with lower()

· 3 min read
Jagdish Kumawat
Founder @ Dewiride

"Basil" and "basil" are different strings to Python, so a check like plant == "basil" fails as soon as someone types a capital letter. lower() gives you a lowercase copy of the text, which makes such checks work. This guide does it on Python 3.15.2.

Syntax​

Syntax
<lowercase_text> = <text>.lower()
PartWhat it means
<text>The string to convert
.lower()Returns a new string with every letter in lowercase
<lowercase_text>The new string. <text> itself doesn't change

The Python documentation says str.lower() will "Return a copy of the string with all the cased characters converted to lowercase."

The Example​

A variable holds the plant name Basil, with a capital B. The script prints it in lowercase, prints the original to show that it didn't change, and then compares the lowercase version with "basil".

Prerequisites​

  • uv and Python 3. This guide uses uv 0.13.10 with Python 3.15.2, in a project made with uv init.

Step 1: Write the Script​

lowercase.py
plant = "Basil"

print(plant.lower())
print(plant)
print(plant.lower() == "basil")

The lowercase.py script in a macOS-style code window: plant is set to Basil, then the script prints plant.lower(), plant, and whether plant.lower() equals basil.

Step 2: Run It​

Terminal
uv run python lowercase.py
Output
basil
Basil
True

The terminal after uv run python lowercase.py: basil, then Basil, then True.

plant.lower() gave basil. plant itself still says Basil, because Python strings can't be changed: the documentation calls them "immutable sequences of Unicode code points", so lower() builds a new string instead. The comparison is True because the lowercase copy matches "basil" exactly. That's how you check text without caring about capital letters. The command works unchanged in PowerShell.

Common Mistakes​

MistakeWhat happensDo this instead
Leaving off the parentheses: plant.lowerPython prints the method itself instead of calling it: <built-in method lower of str object at 0x100c138a0>, with a different address after at on each runAdd the parentheses: plant.lower()
Expecting plant.lower() to change plantplant still prints BasilSave the result: after plant = plant.lower(), print(plant) printed basil

FAQ​

What about letters like ß?​

lower() leaves ß alone, because it's already lowercase. casefold() goes further: "Straße".lower() gave straße, while "Straße".casefold() gave strasse. The documentation explains that "Casefolding is similar to lowercasing but more aggressive because it is intended to remove all case distinctions in a string." Use casefold() when you compare text that can contain such letters.

Does lower() change anything that isn't a letter?​

No. It only converts "cased characters", the letters that have an uppercase and a lowercase form. "Plant 2: BASIL!".lower() gave plant 2: basil!: the digit, the colon, the space and the exclamation mark stayed as they were.

Conclusion​

plant.lower() returned basil, a new lowercase string, while plant stayed Basil. Comparing the lowercase copy with "basil" gave True.

Additional Resources​