str.capitalize()
str.capitalize() str · Updated March 13, 2026 · String Methods The capitalize() method returns a copy of the string with the first character converted to uppercase and all other characters converted to lowercase. It does not modify the original string since strings in Python are immutable.
Syntax
str.capitalize()
Parameters
capitalize() takes no parameters.
Returns: A new string with the first character capitalized and the rest lowercase.
Examples
Basic usage
text = "hello world"
print(text.capitalize())
# Hello world
The method capitalizes the first character while converting everything else to lowercase.
Working with mixed case
# All uppercase becomes first letter capitalized
print("HELLO WORLD".capitalize())
# Hello world
# All lowercase works as expected
print("hello world".capitalize())
# Hello world
# Title case gets converted to proper capitalize style
print("Hello World".capitalize())
# Hello world
Notice that “Hello World” becomes “Hello world” — capitalize() forces all characters after the first to lowercase, rather than preserving their original case.
Numbers and symbols at the start
# Numbers at the start stay as-is, rest gets lowercased
print("123ABC".capitalize())
# 123abc
# Symbols at the start stay, rest gets lowercased
print("!hello".capitalize())
# !hello
When the first character is not an alphabetic letter, it remains unchanged and subsequent letters are still converted to lowercase.
Empty strings
print("".capitalize())
# (empty string)
Common Patterns
Preparing user input for display
def format_name(name):
"""Capitalize a name for display."""
return name.capitalize()
print(format_name("alice"))
# Alice
print(format_name("ALICE"))
# Alice
This is useful when you want consistent formatting for names, titles, or other proper nouns.
In list comprehensions
words = ["apple", "BANANA", "Cherry"]
capitalized = [word.capitalize() for word in words]
print(capitalized)
# ['Apple', 'Banana', 'Cherry']
Sentence capitalization
# Fixing all-lowercase sentences
message = "this is a sentence."
print(message.capitalize())
# This is a sentence.
# Note: this only capitalizes the first letter
message = "first. second."
print(message.capitalize())
# First. second.
capitalize() only affects the very first character, not each sentence.
Errors
capitalize() never raises an exception. It works on any string, including empty strings.