Python String istitle() Method
istitle() is an inbuilt string function that returns True if all the words in the string are title cased otherwise returns False.
What is 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.
Syntax:
string.istitle()
Parameters:
The istitle() method doesn’t take any parameters.
Returns:
True if the string is a title-cased string otherwise returns False.
Example 1
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 = 'geeks 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
Python3
s = 'I Love Geeks For Geeks' if s.istitle() = = True : print ( 'Titlecased String' ) else : print ( 'Not a Titlecased String' ) s = 'I Love geeks for geeks' if s.istitle() = = True : print ( 'Titlecased String' ) else : print ( 'Not a Titlecased String' ) |
Output:
Titlecased String Not a Titlecased String