Python String istitle() Method
The istitle()
method checks if a string is in title case. In title case, the first letter of each word is uppercase and the remaining letters are lowercase.
Syntax
string.istitle()
Parameters
No parameters.
Return Value
Returns True
if every word of the string starts with an uppercase letter, followed by lowercase letters. Numbers and symbols are ignored.
Returns False
otherwise.
Examples
Check if the String is in Title Case
print("Hello World".istitle()) # True
print("Hello world".istitle()) # False (second word not capitalized)
print("HELLO WORLD".istitle()) # False (all letters uppercase)
print("123 Python".istitle()) # True
print("Python 3".istitle()) # True
print("123".istitle()) # False (no letters)
print("".istitle()) # False (empty string)