Skip to content
Tutorials Center
My learning

Topics

Python Reference ยท String Methods

Python str.istitle() method

Reference for Python str.istitle(): check whether words start with a capital and continue in lower case, how apostrophes and hyphens behave, and the link to title().

The istitle() method returns True if the string is title-cased: each run of letters starts with an upper-case letter and continues with lower-case letters only. Any character that is not a letter, such as a space, digit, hyphen or apostrophe, ends a run, so the next letter must be capitalized again.

It tests the same pattern that title() produces, but only for strings that contain at least one cased character.

Python
print("Hello World".istitle())   # True
print("Hello world".istitle())   # False

Try it

Python Which strings are title-cased

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Python Apostrophes and title()

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Syntax

Python
str.istitle()

This method takes no parameters.

Return value: True if the string has at least one cased character, upper-case letters only follow uncased characters, and lower-case letters only follow cased ones; otherwise False.

Raises: nothing.

Usage notes

  • Needs a letter. "123".istitle() and "".istitle() are False.
  • Every word counts. One lower-case word start, as in "Hello world", makes the result False. One capital inside a word, as in "HeLlo", also does.
  • All caps fails. "NASA".istitle() is False because only the first letter of a run may be upper case.
  • Apostrophes split words. "They're".istitle() is False, because the r after the apostrophe starts a new run and is not capitalized, and "They'Re" is True. This matches the odd output of title(), which turns "they're" into "They'Re".
  • Better alternative for real text. string.capwords() splits on whitespace and capitalizes each word, giving "They're". Its result does not always satisfy istitle().
  • Digits and symbols are uncased, so "Python 3 Rocks".istitle() is True.
  • Title-case letters. Special characters like ว… are title-case themselves and are treated as upper case here.