str.title()

Added in v3.x · Updated March 13, 2026 · String Methods
string method stdlib

The .title() method returns a titlecased version of the string. In this version, the first character of each word is converted to uppercase and the remaining characters are converted to lowercase.

Syntax

str.title()

Parameters

.title() takes no parameters.

Return Value

Returns a new string with the first character of each word converted to uppercase.

Examples

Basic Usage

>>> "hello world".title()
'Hello World'

>>> "python programming".title()
'Python Programming'

Handling Apostrophes

>>> "don't worry".title()
"Don'T Worry"

>>> "it's a beautiful day".title()
"It's A Beautiful Day"

The method treats apostrophes as word boundaries, but the behavior can be unexpected for contractions.

Numbers in Strings

>>> "python3 tutorial".title()
'Python3 Tutorial'

>>> "100 days of code".title()
'100 Days Of Code'

Numbers embedded in words are treated as word boundaries.

Common Use Cases

  • Display titles: Converting user input to title case for UI display
  • Data normalization: Standardizing string formatting in data processing pipelines
  • Report generation: Creating formatted headers for reports and documents
  • Content processing: Preparing text for blogs, articles, or documentation

Practical Example

# Processing user-submitted titles
user_titles = [
    "python programming",
    "web development basics",
    "data science introduction"
]

for title in user_titles:
    print(title.title())

# Output:
# Python Programming
# Web Development Basics
# Data Science Introduction

Edge Cases to Consider

  1. Contractions: Words like “don’t” become “Don’T” — consider using the string.capwords() function for better handling
  2. All uppercase: “HELLO”.title() returns “Hello” (only first letter capitalized)
  3. Mixed case: Already titlecased strings remain unchanged
  4. Numbers: Embedded numbers create word boundaries (“python3” → “Python3”)

Differences From capitalize()

The .title() method and .capitalize() method behave differently:

>>> "hello world".title()
'Hello World'

>>> "hello world".capitalize()
'Hello world'
  • .title(): Capitalizes the first letter of each word
  • .capitalize(): Capitalizes only the first character of the entire string

See Also