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:
Introduction to Scientific Programming with Python - Joakim Sundnes
Python Program to Extract Extension From the File Name
Adding a Newline Character to a String in Java
Python String isnumeric()
Python Tuple index()
Python Program to Find the Square Root
Python Program to Convert Decimal to Binary Using Recursion
Python Global, Local and Nonlocal variables
Python format()
Python List index()
Python Dictionary
Python String replace()
Python Global Keyword
Python List reverse()
Converting String to Stream of chars
Applied Text Analysis with Python - Benjamin Benfort & Rebecca Bibro & Tony Ojeda
Python strftime()
Python Program to Convert Bytes to a String
Learning scikit-learn Machine Learning in Python - Raul Garreta & Guillermo Moncecchi
Python len()
Python Program to Compute the Power of a Number
Python Program to Convert String to Datetime
Encode a String to UTF-8 in Java
Python String title()
Python Program to Make a Flattened List from Nested List
Python Custom Exceptions
Python pow()
Python Program to Swap Two Variables
Python Program to Create Pyramid Patterns
Python Program to Copy a File
Python dict()
Format ZonedDateTime to String