The str.istitle() method returns True if the string is in title case — meaning every word begins with an uppercase character followed only by lowercase letters. It returns False if any word starts with lowercase, contains uppercase letters in the middle, or if the string lacks cased letters altogether.
Uncased Character Boundary Rule: In Python, any non-letter character (digits, spaces, hyphens, and apostrophes) is uncased. The letter immediately following any uncased character is treated as the start of a new word. Consequently, "O'Connor".istitle() is True, but "They're".istitle() is False.
The istitle() method takes no arguments and evaluates string capitalization:
is_titlecased = string.istitle()
| Parameter | Type | Description |
|---|---|---|
| None | — | Takes zero arguments. Passing parameters raises TypeError. |
| Return Value | bool |
Returns True if string is titlecased and contains ≥ 1 cased letter; otherwise False. |
In standard English typography, title case capitalizes the first letter of each word and keeps subsequent characters in lowercase:
# Valid titlecased strings (return True)
print("Welcome To Plus2Net".istitle()) # True
print("Python Programming".istitle()) # True
print("A B C".istitle()) # True (single-letter uppercase words)
# Non-titlecased patterns (return False)
print("Welcome to plus2net".istitle()) # False: 'to' and 'plus2net' start lowercase
print("WELCOME TO PYTHON".istitle()) # False: ALL CAPS is not title case
print("welcome to python".istitle()) # False: all lowercase
print("PyThon".istitle()) # False: internal uppercase 'T'
Output:
True
True
True
False
False
False
False
Python defines title case strictly based on cased vs. uncased transitions. Any punctuation mark, digit, or symbol is uncased. Any letter that follows an uncased character is expected to be uppercase:
# 1. The Apostrophe Quirk
print("O'Connor".istitle()) # True: 'C' is uppercase after uncased "'"
print("O'connor".istitle()) # False: 'c' is lowercase after uncased "'"
print("They're".istitle()) # False: 'r' is lowercase after uncased "'"
print("They'Re".istitle()) # True: 'R' is uppercase after "'"
# 2. Hyphenated compound words
print("Jean-Luc".istitle()) # True: 'L' is uppercase after "-"
print("Jean-luc".istitle()) # False: 'l' is lowercase after "-"
# 3. Numbers preceding words
print("100 Days Of Code".istitle()) # True: digits don't affect following words
print("1st Place".istitle()) # False: 's' is lowercase immediately after digit '1'
print("1St Place".istitle()) # True: 'S' is uppercase immediately after digit '1'
Output:
True
False
False
True
True
False
True
False
True
str.title() uses the exact same uncased transition algorithm, calling "they're".title() results in "They'Re". Understanding this transition is essential for building natural-language title formatters.
To evaluate to True, the string must contain at least one cased character. Strings consisting entirely of numbers, punctuation, whitespace, or empty strings evaluate to False:
# No cased letters: evaluate to False
print("12345".istitle()) # False
print("---".istitle()) # False
print(" ".istitle()) # False
print("".istitle()) # False
# Digits alongside valid titlecased words evaluate to True
print("Chapter 1: The Beginning".istitle()) # True
Output:
False
False
False
False
True
The table below summarizes how Python's case-checking methods behave across different casing styles:
| String | istitle() |
isupper() |
islower() |
str.capitalize() Matches? |
|---|---|---|---|---|
"Hello World" | True | False | False | False (only 1st letter) |
"Hello world" | False | False | False | True |
"HELLO WORLD" | False | True | False | False |
"hello world" | False | False | True | False |
"100 Python" | True | False | False | True |
"" (empty) | False | False | False | True |
Editorial guidelines often mandate title case for article headings while permitting standard minor stop-words (such as a, an, the, and, in, of) in lowercase:
STOP_WORDS = {"a", "an", "the", "and", "but", "or", "for", "nor", "on", "at", "to", "by", "in", "of"}
def is_editorial_title_case(heading):
words = heading.strip().split()
if not words:
return False
for i, w in enumerate(words):
# First and last words must always be capitalized
if i == 0 or i == len(words) - 1:
if not w.istitle():
return False
elif w.lower() in STOP_WORDS:
if not w.islower():
return False
else:
if not w.istitle():
return False
return True
print(is_editorial_title_case("The Power of Asynchronous Python")) # True
print(is_editorial_title_case("the power of asynchronous python")) # False
Output:
True
False
Auditing CRM contact records to identify unformatted names (e.g. "john smith" or "JOHN SMITH") that need normalization:
contacts = ["Jane Doe", "JOHN SMITH", "mary johnson", "Dr. David Miller"]
needs_formatting = [name for name in contacts if not name.istitle()]
print("Contacts needing formatting:", needs_formatting)
Output:
Contacts needing formatting: ['JOHN SMITH', 'mary johnson']
The following production script implements an AP-style headline linter and personal name title case validator with automated self-checking assertions:
class TitleStyleLinter:
LOWERCASE_ARTICLES = {"a", "an", "the", "and", "but", "or", "for", "in", "on", "of", "to"}
def is_strict_title(self, text):
# Pure Python istitle check
if not isinstance(text, str):
return False
return text.istitle()
def is_headline_title(self, headline):
# Allows recognized minor articles in lowercase between capitalized words
if not isinstance(headline, str):
return False
tokens = headline.strip().split()
if not tokens:
return False
for idx, tok in enumerate(tokens):
clean = tok.strip(".,!?:;\"'")
if idx == 0 or idx == len(tokens) - 1:
if not clean.istitle():
return False
elif clean.lower() in self.LOWERCASE_ARTICLES:
if not clean.islower():
return False
else:
if not clean.istitle():
return False
return True
# --- Unit Assertions and Verification ---
linter = TitleStyleLinter()
# 1. Strict title tests
assert linter.is_strict_title("Welcome To Python") is True
assert linter.is_strict_title("Welcome to Python") is False # 'to' lowercase
assert linter.is_strict_title("100 Days Of Python") is True
assert linter.is_strict_title("12345") is False # No cased letters
assert linter.is_strict_title("") is False
# 2. Name apostrophe quirk
assert linter.is_strict_title("O'Connor") is True
assert linter.is_strict_title("Jean-Luc") is True
# 3. Headline style linter tests (permits lowercase stop words)
assert linter.is_headline_title("The Art of Computer Programming") is True
assert linter.is_headline_title("A Guide to Modern Python") is True
assert linter.is_headline_title("a guide to modern python") is False
print("Strict title 'Welcome To Python':", linter.is_strict_title("Welcome To Python"))
print("Headline 'A Guide to Modern Python':", linter.is_headline_title("A Guide to Modern Python"))
print("All str.istitle() unit assertions passed successfully!")
Open in Google Colab View on GitHub
Run all title case inspection examples interactively, evaluate apostrophe and hyphen uncased boundaries, test editorial headline linters, and audit directory names in Google Colab.
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.