Python String istitle() Method
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
s = 'Geeks For Geeks'
print (s.istitle())
s = 'geeks For Geeks'
print (s.istitle())
s = 'Geeks For GEEKs'
print (s.istitle())
s = '6041 Is My Number'
print (s.istitle())
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 geeks for geeks'
if s.istitle() = = True :
print ( 'Titlecased String' )
else :
print ( 'Not a Titlecased String' )
|
Output:
Titlecased String
Not a Titlecased String
Last Updated :
18 Aug, 2022
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...