Python String | istitle ()

Python Methods and Functions | String Variables

what is titlecased?

A string with the first character in each word in uppercase and all remaining characters in lowercase.

Syntax :

string.istitle ()

Parameters :

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

string otherwise it returns False.

CODE 1

# First character in each word
# uppercase and remaining lowercase

s = ' Geeks For Geeks'

print (s.istitle ())

  
# First character in first
# lowercase word

s = 'geeks For Geeks'

print (s.istitle ())

 
# Third word in uppercase
# characters in the middle

s = 'Geeks For GEEKs'

print (s.istitle ())

 

s = ' 6041 Is My Number'

print (s.istitle ())

 
# uppercase word
# characters in the middle

s = 'GEEKS'

print (s.istitle ())

Output:

 True False False True False 

Code 2

s = 'I Love Geeks For Geeks'

 

if s.istitle () = = True :

print ( < code class = "string"> '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