Python title() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
String

Definition

title() returns a string in title case: the first letter of every word is upper case and the rest of the letters are lower case. "the python handbook" becomes "The Python Handbook".

A "word" for title() is any run of letters, and any character that is not a letter starts a new word. That includes apostrophes and digits, which causes a well known surprise: "they're" becomes "They'Re". The original string is never changed.

text.title() is a method of the built-in str type: call it on a string with dot notation. No import is needed, and it never changes the original string.

Syntax

Call it on any string. There are no arguments, but the parentheses are required.

python
result = text.title()
CallWhat it does
"hello world".title()Returns 'Hello World'.
"they're bill's friends".title()Returns "They'Re Bill'S Friends". Each apostrophe starts a new "word", so the letter after it becomes a capital.
"3rd place".title()Returns '3Rd Place'. A digit is not a letter, so the letter after it starts a word.

For names with apostrophes use string.capwords() from the standard library, which splits on spaces only. To capitalize only the first letter of the whole text use capitalize(), and to test for title case use istitle().

Library declarations
python
str.title() -> str
# returns: a new string; the original is unchanged
# raises: nothing (works for any string)

Parameters

title() takes no arguments. It always works on the whole string.

Return Value

Return ValueDescription
strA new string in title case. The original string is not changed.

Python Examples

Example 1 — Turn a Phrase Into a Title

Convert a lower case phrase and a shouted phrase to title case.

python
book = "the python handbook"
shout = "LEARN PYTHON TODAY"

print(book.title())
print(shout.title())
print(book)

How It Works

  1. Each word starts big. title() turns the first letter of every word into a capital.
  2. The rest becomes small. In the shouted text, the other letters are changed to lower case, so "LEARN" becomes "Learn".
  3. The original is unchanged. book still prints in lower case, because the method returns a new string.

Example 2 — Fix the Apostrophe Problem

See what title() does with apostrophes, and compare it with string.capwords().

python
import string

text = "they're here, and it's late"

print(text.title())
print(string.capwords(text))

How It Works

  1. The trap. title() treats each apostrophe as the end of a word, so it prints They'Re and It'S.
  2. A better tool. string.capwords() splits the text on spaces only, so the apostrophes cause no trouble.
  3. Watch the comma. The word here, keeps its comma, which belongs to the word because capwords splits on spaces only.

Example 3 — Format a List of Names

Clean names that arrive in different cases and print them in one style.

python
names = ["ada lovelace", "ALAN TURING", "gRACE hOPPER"]

for name in names:
    print(name.title())

print("Ada Lovelace".istitle(), "ADA LOVELACE".istitle())

How It Works

  1. Three messy inputs. The names arrive in lower case, upper case, and mixed case.
  2. One call fixes all. title() forces the capital-then-small pattern on each word, so the output is consistent.
  3. Check the pattern. istitle() is True for "Ada Lovelace" and False for the shouted version.

Frequently Asked Questions

It returns a copy of the string in which the first letter of each word is upper case and all other letters are lower case.
title() starts a new word after every character that is not a letter, including apostrophes. Use string.capwords() when the text contains apostrophes.
title() capitalizes every word. capitalize() capitalizes only the first letter of the whole string and makes the rest lower case.
No. Strings are immutable, so title() returns a new string. Assign the result to keep it.
Call istitle(), which returns True when every word starts with a capital and the other letters are lower case.

Next: translate()

Return a copy with each character mapped through a translation table.

translate() tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

11 people found this page helpful