English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Python Basic Tutorial

Python Flow Control

Fonction en Python

Types de données en Python

Python File Operations

Python Objects and Classes

Python Date and Time

Advanced Python Knowledge

Python Reference Manual

Python string istitle() usage and example

Python string methods

Check if all the words in the string are spelled with the first letter capitalized and the other letters are lowercase. If they are, istitle() returns True. If not, it returns False.

The syntax of the istitle() method is:

string.istitle()

The istitle() parameter

The istitle() method does not take any parameters.

The return value of istitle():

The return value of istitle():

  • If all the words in the string are spelled with the first letter capitalized and the other letters are lowercase, it returns True, otherwise it returns False.

Example1The work of istitle():

s = 'Python Is Good.'
print(s.istitle())
s = 'Python is good'
print(s.istitle())
s = 'This Is @ Symbol.'
print(s.istitle())
s = ''99 Is A Number
print(s.istitle())
s = 'PYTHON'
print(s.istitle())

When running the program, the output is:

True
False
True
True
False

Example2How to use istitle()?

s = 'I Love Python.'
if s.istitle() == True:
  print('istitle() is true')
else:
  print('istitle() is false')
  
s = 'PYthon'
if s.istitle() == True:
  print('istitle() is true')
else:
  print('istitle() is false')

When running the program, the output is:

istitle() is true
istitle() is false

Python string methods