Python String istitle() Method is a built-in string function that returns True if all the words in the string are title cased, otherwise returns False.
Python String istitle() Method Syntax
Syntax: string.istitle()
Returns: True if the string is a title-cased string otherwise returns False.
Python String istitle() Method Example
Python3
string = "Geeks" print (string.istitle()) |
Output:
True
What is a title case?
When all words in a string begin with uppercase letters and the remaining characters are lowercase letters, the string is called title-cased. This function ignores digits and special characters.
Example 1:
More Examples on Python String istitle() Method
Python3
# First character in each word is # uppercase and remaining lowercase s = 'Geeks For Geeks' print (s.istitle()) # First character in first # word is lowercase s = 'Lazyroar For Geeks' print (s.istitle()) # Third word has uppercase # characters at middle s = 'Geeks For GEEKs' print (s.istitle()) # Ignore the digit 6041, hence returns True s = '6041 Is My Number' print (s.istitle()) # word has uppercase # characters at middle s = 'GEEKS' print (s.istitle()) |
Output:
True False False True False
Example 2: Condition Checking using istitle() method
Checking if a string is title cased using Python String istitle() Method.
Python3
s = 'I Love Geeks For Geeks' if s.istitle() = = True : print ( 'Titlecased String' ) else : print ( 'Not a Titlecased String' ) s = 'I Love Lazyroar for Lazyroar' if s.istitle() = = True : print ( 'Titlecased String' ) else : print ( 'Not a Titlecased String' ) |
Output:
Titlecased String Not a Titlecased String