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:
Format ZonedDateTime to String
Python Set clear()
Python Program to Remove Duplicate Element From a List
APIs in Node.js vs Python - A Comparison
Python Program to Get Line Count of a File
Python bytearray()
Python Dictionary
Python ascii()
Python len()
Python Objects and Classes
Python Program to Find HCF or GCD
Python Set copy()
Python time Module
Python Set difference()
Introduction to Machine Learning with Python - Andreas C.Muller & Sarah Guido
Python id()
Python String zfill()
Python Program to Convert Celsius To Fahrenheit
Python @property decorator
Python property()
Python strptime()
JavaScript Methods of RegExp and String
How to get current date and time in Python?
Convert String to Byte Array and Reverse in Java
Python Program to Slice Lists
Converting String to Stream of chars
Java InputStream to String
Python hash()
Python String swapcase()
Python List remove()
Python frozenset()
Python String isnumeric()