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 Check the File Size
Reading an HTTP Response Body as a String in Java
Python Program to Slice Lists
Python timestamp to datetime and vice-versa
Python Program to Convert Celsius To Fahrenheit
Python Data Types
Python Numbers, Type Conversion and Mathematics
Python max()
Python String rjust()
Python Program to Safely Create a Nested Directory
Python Dictionary keys()
Python iter()
Python Program to Delete an Element From a Dictionary
Python Program to Find the Sum of Natural Numbers
Case-Insensitive String Matching in Java
Python Deep Learning Cookbook - Indra den Bakker
Adding a Newline Character to a String in Java
Python Functions
Python String rindex()
Python map()
Python complex()
Python Dictionary values()
Python String find()
Python isinstance()
Python Program to Measure the Elapsed Time in Python
Python for Programmers with introductory AI case studies - Paul Deitel & Harvey Deitel
Python list()
Python List pop()
Python Program to Get the File Name From the File Path
Python Anonymous / Lambda Function
Python Program to Concatenate Two Lists
Python str()