str.istitle()
Check that a string matches str.title()'s output — a very strict definition that trips even short apostrophes.
Demo
istitle() applies Python's strict title-case definition: every uppercase character may ONLY follow a non-cased character (space, punctuation, digit, start of string). Every lowercase character may ONLY follow a cased character. The classic surprise: the apostrophe in "Don't" is non-cased, so the "t" after it should be uppercase — meaning "Don't" is NOT title case per Python, but "Don'T" is. This matches str.title() but rarely matches human intuition.
Common patterns
if not headline.istitle(): raise ValueError("headline must be title case")
if not text.istitle(): text = text.title()
# "MyClass".istitle() is False # because "C" follows a cased "y"
Examples
Pitfalls
"Don\'t Stop".istitle()
"Don\'T Stop".istitle()
"MyClass".istitle()
"My Class".istitle()
"".istitle()
s and s.istitle()
"Chapter1Intro".istitle()
When to use
- Validating that a headline has been passed through str.title()
- Detecting non-normalized formatted text
- Composing with capitalize / title / isupper / islower for finer checks
- Confirming a string matches Python's specific title-case convention
- Human-friendly title case (which allows apostrophes) → custom regex
- Detecting camelCase or PascalCase → different pattern entirely
- Locale-aware title case → third-party library
- You need "is capitalized" not "is title case" → check first char via s[0].isupper()
Notes
FAQ
Because Python treats the apostrophe as a word break. After a word break, the next cased character should be uppercase — but "t" is lowercase. This matches str.title() output, which produces "Don'T".