Table of Contents
The istitle() returns True if the string is a titlecased string. If not, it returns False.
The syntax of istitle() method is:
string.istitle()
1. istitle() Parameters
The istitle() method doesn’t take any parameters.
2. Return Value from istitle()
The istitle() method returns:
Trueif the string is a titlecased stringFalseif the string is not a titlecased string or an empty string
3. Example 1: Working 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())
Output
True False True True False
4. Example 2: How to use istitle()?
s = 'I Love Python.'
if s.istitle() == True:
print('Titlecased String')
else:
print('Not a Titlecased String')
s = 'PYthon'
if s.istitle() == True:
print('Titlecased String')
else:
print('Not a Titlecased String')
Output
Titlecased String Not a Titlecased String
Related posts:
Python Program to Multiply Two Matrices
Python String swapcase()
Python Global, Local and Nonlocal variables
JavaScript Eval: run a code string
Java InputStream to String
Python Program to Get Line Count of a File
Python Recursion
Python locals()
Python Program to Access Index of a List Using for Loop
Python Set discard()
Python delattr()
Java InputStream to String
Python RegEx
Python Program to Find Armstrong Number in an Interval
Python Inheritance
Python String format()
Python datetime
Python Program to Differentiate Between type() and isinstance()
Python Set issuperset()
Python String isdecimal()
Python hasattr()
Python Dictionary fromkeys()
Python String lstrip()
Python String upper()
Python Deeper Insights into Machine Learning - Sebastian Raschka & David Julian & John Hearty
Python Program to Add Two Matrices
Python hex()
Python List pop()
Applied Text Analysis with Python - Benjamin Benfort & Rebecca Bibro & Tony Ojeda
Python Set isdisjoint()
Python format()
Array to String Conversions