.title()

Anonymous contributor's avatar
Anonymous contributor
Anonymous contributor's avatar
Anonymous contributor
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.

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:

us
Visit us
code
Hide code
Code
Output
Hide output
Hide output
Loading...

All contributors

Looking to contribute?

Learn Python on Codecademy