Skip to content
Related Articles

Related Articles

Improve Article

Python String istitle() Method

  • Difficulty Level : Medium
  • Last Updated : 12 Aug, 2021
Geek Week

Python String istitle() method returns True if the string is a titlecased string otherwise it returns False. What is titlecased? The string which has the first character in each word Uppercase and remaining all characters Lowercase alphabets. 

Syntax: 

string.istitle()

Parameters: 

The istitle() method doesn’t take any parameters.



Returns: 

True if the string is a titlecased string otherwise it returns False.

Example 1

Python3




# First character in each word is 
# uppercase and remaining lowercases
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())
  
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

 Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.  

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course




My Personal Notes arrow_drop_up
Recommended Articles
Page :