.title()
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:
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn Python on Codecademy
- Skill path
Analyze Data with Python
Learn to analyze and visualize data using Python and statistics.Includes 8 CoursesWith CertificateIntermediate13 hours - Course
Learn Python 3
Learn the basics of Python 3.12, one of the most powerful, versatile, and in-demand programming languages today.With CertificateBeginner Friendly23 hours