The istitle()
method is a string method in Python which returns True if the string's first character of each word is in uppercase and all other characters are in lowercase. Otherwise it returns False.
Parameter Values
This function does not accept any parameters.Return Values
The istitle()
method in Python returns a bool
, either True
or False
.
How to Use istitle()
in Python
Example 1:
The istitle()
method returns True
if all words in a string start with an uppercase letter, followed by only lowercase letters.
print('Hello World'.istitle()) # Output: True
Example 2:
If the string contains non-letter characters or all words do not start with an uppercase letter, istitle()
will return False
.
print('Hello world'.istitle()) # Output: False
Example 3:
Empty strings or strings with no alphabetical characters will return False
.
print('12345'.istitle()) # Output: False