Python Glossary Русский

all Python 3Strings (str)function

str.istitle

character checks

True if the string is titlecased: each word starts with an uppercase letter.

Syntax

s.istitle()

Any non-letter counts as a word boundary, so apostrophes defeat intuition: "They're" is False, while Python considers "They'Re" properly titlecased. str.title() follows the same rule, which is why it mangles names like O'Brien. For real-world headings the method is close to useless — it encodes a mechanical casing rule, not language.

Examples

print('Hello World'.istitle())  # → True
print('hello world'.istitle())  # → False
print('HELLO'.istitle())        # → False

See also

Open in the full glossarydocs.python.orgReport an inaccuracy