istitle() returns True when the string is written in title case: every word begins with an upper case letter, and the other letters of the word are lower case. "Python Tutorial" passes, while "Python tutorial" does not.
The string must contain at least one letter. A capital letter may only follow a character that is not a letter, and a lower case letter may only follow another letter. That is the same rule that title() uses to build title case, so text.title().istitle() is normally True.
text.istitle() is a method of the built-in str type: call it on a string with dot notation. No import is needed, and it never changes the original string.
Syntax
Call it on any string. There are no arguments, but the parentheses are required.
python
ok = text.istitle()
Call
What it does
"Hello World".istitle()
Returns True. Each word starts with a capital and continues in lower case.
"Hello world".istitle()
Returns False. The second word starts with a lower case letter.
"HELLO".istitle()
Returns False. A capital letter may not follow another letter.
To convert text to title case use title(). To check for all capitals use isupper().
Library declarations
python
str.istitle() -> bool
# returns: True if the string is in title case and has at least one letter
# an empty string returns False
Parameters
This method takes no arguments. It always checks the whole string.
Return Value
Return Value
Description
bool
True if the string is in title case and contains at least one letter, otherwise False.
Python Examples
Example 1 — Is This Text in Title Case?
Check a title, lower case text, half-capitalized text, and shouted text.
python
samples = ["Python Tutorial", "python tutorial", "Python tutorial", "PYTHON"]
for text in samples:
print(repr(text), text.istitle())
A real title. Both words start with a capital and continue in lower case, so the result is True.
Wrong start."python tutorial" starts its words with lower case letters, so it is False.
One word is not enough."Python tutorial" has a lower case second word, and "PYTHON" has capitals after the first letter.
Example 2 — Fix Text Only When Needed
Run title() only on strings that fail the check.
python
headline = "the quick brown fox"
print(headline.istitle())
if not headline.istitle():
headline = headline.title()
print(headline)
print(headline.istitle())
Output
False
The Quick Brown Fox
True
How It Works
The check fails first. The headline is all lower case, so istitle() prints False.
title() repairs it. Inside the if, title() returns a title case copy, which replaces the old value.
The check now passes. After the change, istitle() is True.
Example 3 — Apostrophes and istitle()
See which spelling of a contraction counts as title case.
python
for text in ["They're Here", "They'Re Here", "Mary's Lamb"]:
print(text, text.istitle())
print("3rd Place".istitle())
Output
They're Here False
They'Re Here True
Mary's Lamb False
False
How It Works
The natural spelling fails. In They're, the r after the apostrophe is lower case and follows a non-letter.
The odd spelling passes.They'Re is exactly what title() would produce, so it satisfies the rule.
Digits count as non-letters too. In 3rd Place the r follows the digit 3 and is lower case, so the answer is False.
Frequently Asked Questions
It returns True if the string is in title case: every word starts with an upper case letter and the other letters are lower case.
After the apostrophe the letter r is lower case but follows a character that is not a letter, which breaks the rule. title() would write it as They'Re.
False. The string needs at least one letter.
Call title(), for example text = text.title(). For names with apostrophes, string.capwords() often works better.
isupper() is True when all letters are capitals. istitle() is True when only the first letter of each word is a capital.