Uppercase to Lowercase Python Methods (With Examples)
November 11, 2026 · 9 min read
Uppercase to Lowercase Python Methods: lower(), casefold() and title()
For an uppercase to lowercase Python conversion, call s.lower(). It returns a new string with every cased letter in lowercase and leaves digits, spaces and punctuation alone. Python ships five more case methods, and a few of them behave in ways that catch people out. Here's what each one does and where it breaks.
How to Convert Uppercase to Lowercase in Python with lower()
str.lower() takes no arguments and gives you back a lowercased copy. The original string stays exactly as it was, because Python strings are immutable. If you want to keep the result, assign it to a name.
headline = "HELLO World 2026!"
print(headline.lower()) # hello world 2026!
print(headline) # HELLO World 2026! (unchanged)
headline = headline.lower() # reassign to keep it
Only letters change. The digits, the space and the exclamation mark come through untouched.
The method isn't limited to A to Z either. The Python docs say it follows the default case conversion in the Unicode Standard, so "ÉCOLE".lower() returns "école" and "ΣΑΣ".lower() returns "σας", with the final sigma handled correctly. A common real-world use is cleaning input before you store it: email.strip().lower() turns " Ana@Example.COM " into "ana@example.com".
Calling the Method Correctly: Is It .lower or lower()?
It's lower(), with parentheses. Writing name.lower without them doesn't raise an error. It gives you the method object itself, and that quiet behaviour hides a classic bug:
name = "Bob"
if name.lower == "bob": # compares a method to a string
print("match") # never runs
print(name.lower) # <built-in method lower of str object at 0x...>
print(name.lower() == "bob") # True
The second trap is calling it on a list. ["A", "B"].lower() raises AttributeError: 'list' object has no attribute 'lower', because only strings have the method. Lowercase each item instead:
words = ["Apple", "BANANA", "Cherry"]
lowered = [w.lower() for w in words] # ['apple', 'banana', 'cherry']
lowered = list(map(str.lower, words)) # same result
If the list might hold None or numbers, the comprehension fails on those items too. Filter them with isinstance(w, str) or convert them with str(w) first. In pandas, use the column version, df["name"].str.lower(), which keeps missing values as missing instead of raising.
Lowercase to Uppercase in Python with upper()
Going the other way, from lowercase to uppercase in Python, uses str.upper(). It mirrors lower(): a new string comes back, and anything without case is left alone.
print("order #42 shipped".upper()) # ORDER #42 SHIPPED
print("ABC123".isupper()) # True
print("123".isupper()) # False
That last line surprises people. isupper() and islower() return True only when the string contains at least one cased character, so a string of digits is neither upper nor lower.
Uppercasing can also change a string's length. German ß has no single-letter capital in the default mapping, so "Straße".upper() returns "STRASSE", growing from 6 characters to 7. The ligature "fi" becomes the two letters "FI". If your code slices strings by position after changing case, measure the new string rather than reusing the old length.
casefold() vs lower(): Case-Insensitive String Comparison
str.casefold() exists for one job: comparing strings while ignoring case. The docs describe it as more aggressive than lower(), because it removes every case distinction. It was added in Python 3.3.
print("ß".lower()) # ß (already lowercase, so nothing changes)
print("ß".casefold()) # ss
print("STRASSE".lower() == "straße".lower()) # False
print("STRASSE".casefold() == "straße".casefold()) # True
The same idea works for lookups and sorting. Fold the stored values once, then fold whatever you check against them:
blocked = {"spam", "Straße"}
folded = {w.casefold() for w in blocked}
print("STRASSE".casefold() in folded) # True
names = ["banana", "Cherry", "apple"]
print(sorted(names)) # ['Cherry', 'apple', 'banana']
print(sorted(names, key=str.casefold)) # ['apple', 'banana', 'Cherry']
Plain sorted() orders by code point, so ASCII capitals come first, which is rarely what a reader expects. We prefer casefold() for comparisons, lookups and sort keys, and lower() for anything a person will read. Casefolded text can look odd on screen, but it gives the right answer when you check whether two strings match.
There's a limitation neither method fixes: they aren't locale-aware. "I".lower() always returns "i", which is wrong in Turkish, where it should be the dotless ı. Going the other way, "İ".lower() returns two code points (an i plus a combining dot above), so its length jumps from 1 to 2. For language-specific rules you need a locale-aware library such as PyICU. JavaScript has locale-aware methods built in, as our guide to uppercase to lowercase in JavaScript shows.
Python Title Case with title() and capitalize()
For Python title case, str.title() uppercases the first letter of each word and lowercases the rest. str.capitalize() works on the whole string instead: it capitalizes only the first character and lowercases everything after it.
text = "hello WORLD"
print(text.title()) # Hello World
print(text.capitalize()) # Hello world
Both lowercase the remaining letters, which isn't always what you want. To uppercase just the first letter and leave the rest alone, slice the string:
name = "mcDonald"
print(name[:1].upper() + name[1:]) # McDonald
Using name[:1] instead of name[0] means an empty string returns "" rather than raising IndexError. For a list of names, [n.title() for n in names] turns ["ada lovelace", "GRACE HOPPER"] into ["Ada Lovelace", "Grace Hopper"].
One detail from the docs: since Python 3.8, capitalize() puts the first character into titlecase rather than uppercase. That only matters for rare digraph letters such as dž, which now become Dž instead of DŽ.
Why Does title() Break on Apostrophes, Acronyms and Numbers?
Title case in Python looks finished until real text hits it. title() treats any run of letters as a word, so an apostrophe or a digit starts a new one:
print("they're bill's friends from the UK".title())
# They'Re Bill'S Friends From The Uk
print("3rd street 2nd floor".title())
# 3Rd Street 2Nd Floor
Those two calls show all three problems. Contractions and possessives get a stray capital, the acronym UK is flattened to Uk, and ordinals come out as 3Rd. The str.title() docs list two workarounds.
The first is string.capwords(), which splits on whitespace only:
import string
print(string.capwords("they're bill's friends")) # They're Bill's Friends
print(string.capwords("hello the UK")) # Hello The Uk
It fixes apostrophes, but it still lowercases the rest of each word, so UK still becomes Uk. Per the string module docs, it also collapses runs of whitespace into single spaces and trims the ends.
The second is a small regex helper, adapted from the docs:
import re
def titlecase(s):
return re.sub(r"[A-Za-z]+('[A-Za-z]+)?",
lambda mo: mo.group(0).capitalize(), s)
print(titlecase("they're bill's friends.")) # They're Bill's Friends.
Its pattern only matches ASCII letters, so "élan" comes out as "éLan". Neither option gives you headline style either, where small words like "of" and "the" stay lowercase. For that you need your own list of minor words and a loop that skips them. The title case rules in AP, APA, Chicago and MLA decide which words go on that list.
swapcase() and Converting Case Without Built-in Methods
str.swapcase() flips every cased letter: "hello WORLD".swapcase() returns "HELLO world". Don't treat it as reversible, though. "ß".swapcase().swapcase() gives "ss", because the first swap expands ß to SS.
Some tutorials convert uppercase to lowercase with a loop instead. It reads each character with ord(), adds 32 to capitals and rebuilds them with chr():
def to_lower(text):
return "".join(
chr(ord(c) + 32) if "A" <= c <= "Z" else c
for c in text
)
print(to_lower("HELLO ÉCOLE")) # hello École
It works for A to Z and nothing else, so the É stays uppercase. It's a fine exercise for learning how character codes work, but in real code lower() is shorter, faster to read and handles accented and non-Latin letters too.
Bytes behave like that loop. b"HELLO".lower() returns b"hello", but bytes.lower() only maps ASCII letters, so the bytes of encoded accented letters pass through unchanged. Decode to str first if you need full case conversion.
Python String Case Methods Compared
Here's every method side by side, run on the same input where that's useful:
| Method | Example | Result | Use it for |
|---|---|---|---|
lower() | "hello WORLD" | "hello world" | Display, storage, normalizing input |
upper() | "hello WORLD" | "HELLO WORLD" | Labels, constants, shouting |
casefold() | "Straße" | "strasse" | Case-insensitive comparison |
title() | "hello WORLD" | "Hello World" | Simple names and labels without apostrophes |
capitalize() | "hello WORLD" | "Hello world" | First letter of a sentence |
swapcase() | "hello WORLD" | "HELLO world" | Rarely needed; not reversible |
string.capwords() | "bill's car" | "Bill's Car" | Title case with apostrophes |
Renaming code identifiers, such as turning userName into user_name, is a different job that needs word-boundary rules, not these methods. Our guide to snake case and camelCase covers that conversion and PEP 8 naming.
For one-off text outside your code, paste it into our case converter. It runs in your browser and offers 11 styles, from upper and lower to sentence and title case. It's a web page, not a Python library, so don't assume its title case matches str.title() output.
If you're documenting these snippets in a README, put them in a fenced block tagged python, as our Markdown code block guide explains. And if your next Python task is turning Markdown into HTML, see our roundup of Python Markdown libraries.
Most uppercase to lowercase Python jobs need one call to lower(). The edge cases above cover nearly everything else: casefold() for comparisons, capwords() or a regex when apostrophes appear, and a length check after Unicode text changes case. When you write up your own notes or docs with these snippets, draft them in the editor. It's free, runs in your browser and needs no account.