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 String isupper()
Python File I/O Operation
CharSequence vs. String in Java
Python List append()
Python max()
Python Statement, Indentation and Comments
Python String isalnum()
Python Program to Get the Full Path of the Current Working Directory
Python Exception Handling Using try, except and finally statement
Python String capitalize()
Python any()
Python Deeper Insights into Machine Learning - Sebastian Raschka & David Julian & John Hearty
Building Chatbots with Python Using Natural Language Processing and Machine Learning - Sumit Raj
Python List pop()
Python sleep()
Python Program to Count the Occurrence of an Item in a List
Python String rsplit()
Python round()
Python Program to Count the Number of Digits Present In a Number
Python Iterators
Python reversed()
Python locals()
Python Functions
Python Shallow Copy and Deep Copy
Python String maketrans()
Python Program to Measure the Elapsed Time in Python
Python object()
Introduction to Machine Learning with Python - Andreas C.Muller & Sarah Guido
Python pass statement
Java InputStream to String
Python Program to Concatenate Two Lists
Jackson – Marshall String to JsonNode