Python .istitle()
Published Oct 9, 2023
The .istitle() string method returns True if the string is in title case and False otherwise. Title case means that the first letter of each word is capitalized, and all other letters in the word are in lowercase.
Syntax
my_string.istitle()
Example
The code below uses .istitle() to check if a string is in title case:
my_string = "I love Codecademy Docs!"print(my_string.istitle())
Output:
False
Codebyte Example
The following code is runnable and uses .istitle() to check if different capitalizations of the same string are in title case:
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