Python .title()

BalaPriyaC's avatar
Published Oct 15, 2021Updated Oct 19, 2021
Contribute to Docs

The .title() string method takes in a string and returns a copy of the string formatted in the title case: each word in the string is capitalized.

  • Learn to analyze and visualize data using Python and statistics.
    • Includes 8 Courses
    • With Certificate
    • Intermediate.
      13 hours
  • Learn the basics of Python 3.12, one of the most powerful, versatile, and in-demand programming languages today.
    • With Certificate
    • Beginner Friendly.
      24 hours

Syntax

string.title()

Example 1

Use .title() to format a string in title case:

my_string = "Codecademy docs"
print(my_string.title())
# Output: Codecademy Docs

Example 2

Use .title() to format author_name in title case:

author_name = "jane smith"
print(author_name.title())
# Output: Jane Smith

Codebyte Example

Use .title() to format the string my_string in title case:

Code
Output
Loading...

All contributors

Contribute to Docs

Learn Python on Codecademy

  • Learn to analyze and visualize data using Python and statistics.
    • Includes 8 Courses
    • With Certificate
    • Intermediate.
      13 hours
  • Learn the basics of Python 3.12, one of the most powerful, versatile, and in-demand programming languages today.
    • With Certificate
    • Beginner Friendly.
      24 hours