The String istitle() method returns True if the string is not empty and it is titlecased. Otherwise, it returns False.
Syntax
my_string.istitle()istitle() Parameters
Python String istitle() method does not take any parameters.
istitle() Return Value
Python String istitle() method returns:
Trueif the string is a titlecased stringFalseif the string is not a titlecased string or it is an empty string
Examples
Example 1: Check if a String is titlecased with istitle()
The istitle() method returns True if the string is a titlecased string.
my_str = 'Tutorial Reference'
print(my_str.istitle()) # Output: Trueoutput
TrueThe istitle() method returns False if the string is not a titlecased string.
For example, a string with all characters uppercase is not a titlecased string:
my_str = 'TUTORIAL REFERENCE'
print(my_str.istitle()) # Output: Falseoutput
FalseSimilarly, a string with all characters lowercase is not a titlecased string:
my_str = 'tutorial reference'
print(my_str.istitle()) # Output: Falseoutput
FalseExample 3: Check if an Empty String is titlecased with istitle()
An empty string is not a titlecased string.
my_str = ''
print(my_str.istitle()) # Output: Falseoutput
FalseExample 3: Check if a String with Numbers is titlecased with istitle()
The istitle() method ignores Numbers.
my_str = 'Tutorial 123 Reference 456'
print(my_str.istitle()) # Output: Trueoutput
TrueExample 4: Check if a String with Special Characters is titlecased with istitle()
The istitle() method ignores Special Characters.
my_str = 'Tutorial, Reference!'
print(my_str.istitle()) # Output: Trueoutput
True