How to Capitalize the First Letter of Every Word in a List Using Python

To capitalize the first letter of every word in a list using Python, call title() on each item inside a list comprehension: [s.title() for s in items]. It returns a new list:

items = ["new york", "salt lake city"]
print([s.title() for s in items])   # ['New York', 'Salt Lake City']

You’ll see real output here; I ran each snippet on Python 3.12.5 in a Windows Command Prompt.

In this tutorial, we’ll capitalize the first letter of every word in a list using Python, fix the apostrophe and acronym bugs in title(), and handle mixed lists.

Capitalize every word in a list with title()

Here’s a lowercase list of US cities. You get a new list back, and the original stays as it was:

cities = ["new york", "los angeles", "san francisco", "salt lake city"]

print([city.title() for city in cities])
print(cities)          # the original list is unchanged

Output:

['New York', 'Los Angeles', 'San Francisco', 'Salt Lake City']
['new york', 'los angeles', 'san francisco', 'salt lake city']
Command Prompt output of Python title() capitalizing every word in a list of US city names
Each city name now starts every word with a capital letter, and the original list still prints in lowercase.

For single-word items, see uppercasing the first letter in a Python list. For one string, read capitalizing each word in a string.

Why does title() break apostrophes and acronyms?

title() starts a new word after any non-letter, so "o'neil's" becomes "O'Neil'S", and "3rd" turns into "3Rd". string.capwords() splits on whitespace only:

import string

shops = ["o'neil's bakery", "joe's 3rd street diner", "NASA visitor center"]

print("title()   :", [s.title() for s in shops])
print("capwords():", [string.capwords(s) for s in shops])

Output:

title()   : ["O'Neil'S Bakery", "Joe'S 3Rd Street Diner", 'Nasa Visitor Center']
capwords(): ["O'neil's Bakery", "Joe's 3rd Street Diner", 'Nasa Visitor Center']
Command Prompt output comparing Python title() and string.capwords() on store names with apostrophes, numbers and acronyms
title() capitalizes the letter after each apostrophe and after the digit; capwords() fixes those but writes O’neil’s, and both lowercase NASA.

Neither keeps NASA in capitals. For custom word rules, you can also use regular expressions in Python.

Keep acronyms with a custom capitalize function

To keep the rest of each word as typed, uppercase only the first character. Splitting on single spaces keeps double spaces, unlike capwords():

def cap_words(text):
    """Uppercase the first letter of each word, keep the rest as typed."""
    return " ".join(w[:1].upper() + w[1:] for w in text.split(" "))

stores = ["NASA visitor center", "apple store on 5th avenue", "the IBM  campus"]

print([cap_words(s) for s in stores])

Output:

['NASA Visitor Center', 'Apple Store On 5th Avenue', 'The IBM  Campus']
Command Prompt output of a custom Python function that capitalizes words in a list but keeps NASA and IBM in capitals
The custom function capitalizes each word, keeps NASA and IBM as typed, and leaves the double space in place.

w[:1] won’t fail on an empty word the way w[0] does. Joining is covered in concatenating a list of strings.

How do you title-case book titles in a list?

Headline style keeps small words like of and the lowercase, except at the start:

SMALL = {"a", "an", "and", "as", "at", "for", "in", "of", "on", "or", "the", "to"}

def headline(text):
    words = text.lower().split()
    return " ".join(w if i and w in SMALL else w.capitalize()
                    for i, w in enumerate(words))

books = ["the grapes of wrath", "of mice and men", "a tale of two cities"]
print([headline(b) for b in books])

Output:

['The Grapes of Wrath', 'Of Mice and Men', 'A Tale of Two Cities']

The i and check always capitalizes the first word. More loop patterns are in the Python for loop guide.

Capitalize words in a list with map()

map() applies a function to every item. Pass the method itself, without parentheses, and wrap the result in list():

import string

states = ["north carolina", "new mexico", "rhode island"]

print(list(map(str.title, states)))
print(list(map(string.capwords, states)))

Output:

['North Carolina', 'New Mexico', 'Rhode Island']
['North Carolina', 'New Mexico', 'Rhode Island']

Both lines print the same states. For filters, a comprehension reads better; see the Python map() function and Python list comprehension.

Capitalize strings in mixed and nested lists

Calling title() on a number or None raises an AttributeError, so check the type first. For a list of lists, nest two comprehensions:

row = ["jane doe", 42, None, "austin texas", 1299.99]
print([x.title() if isinstance(x, str) else x for x in row])

teams = [["boston red sox", "new york yankees"], ["chicago cubs"]]
print([[t.title() for t in group] for group in teams])

Output:

['Jane Doe', 42, None, 'Austin Texas', 1299.99]
[['Boston Red Sox', 'New York Yankees'], ['Chicago Cubs']]

Non-strings pass through untouched. See also lists of lists in Python.

Want more string practice? Try one of these next:

Frequently asked questions

How do I capitalize every word in a list in Python?

Use [s.title() for s in my_list], which returns a new list.

What’s the difference between title() and capitalize()?

title() capitalizes every word; capitalize() only the first letter.

Why does title() turn “don’t” into “Don’T”?

It treats the apostrophe as a word break. Use string.capwords(), which splits on spaces only.

How do I keep acronyms like NASA in capitals?

Uppercase only each first character: w[:1].upper() + w[1:].

How do I skip numbers and None in the list?

Add a type check: [x.title() if isinstance(x, str) else x for x in row].

Where is string.capwords() documented?

See string.capwords() in the Python docs.