Python has built-in string methods that make converting lowercase to uppercase simple. Here are the methods you need to know.
The most common way to convert lowercase to uppercase in Python:
text = "hello world"
result = text.upper()
# Output: "HELLO WORLD"
This converts every character to its uppercase version. Numbers, spaces, and special characters are not affected.
The opposite — converts uppercase to lowercase:
text = "HELLO WORLD"
result = text.lower()
# Output: "hello world"
Capitalizes only the first letter of the string:
"hello world".capitalize()
# Output: "Hello world"
Capitalizes the first letter of every word:
"hello world".title()
# Output: "Hello World"
Flips every character — uppercase becomes lowercase and vice versa:
"Hello World".swapcase()
# Output: "hELLO wORLD"
All these methods return a new string. The original string is not modified. Strings in Python are immutable.
Use a list comprehension to convert multiple strings:
words = ["hello", "world", "python"]
upper_words = [w.upper() for w in words]
# Output: ["HELLO", "WORLD", "PYTHON"]
Convert an entire file to uppercase:
with open("input.txt") as f:
content = f.read().upper()
.upper() — ALL UPPERCASE
.lower() — all lowercase
.capitalize() — First word only
.title() — Every Word Capitalized
.swapcase() — fLIP cASE
These are the most common ways to handle case conversion in Python. For quick non-coding conversions, use our free online case converter tool instead.