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 Find Sum of Natural Numbers Using Recursion
Python Data Analytics with Pandas, NumPy and Matplotlib - Fabio Nelli
Python bin()
Convert String to int or Integer in Java
Python isinstance()
Python Program to Check if a Key is Already Present in a Dictionary
Python Package
Python Multiple Inheritance
Python id()
Python Program to Calculate the Area of a Triangle
Convert char to String in Java
Python Program to Compute the Power of a Number
Python String format_map()
Python Program to Display the multiplication Table
Python Set difference()
Python Program to Make a Simple Calculator
Python String isprintable()
Python Inheritance
Python List append()
Python frozenset()
Python Operator Overloading
JavaScript Methods of RegExp and String
Deep Learning with Python - Francois Chollet
Python Program to Transpose a Matrix
Python ascii()
Python Program to Get File Creation and Modification Date
Python Dictionary keys()
Python Deeper Insights into Machine Learning - Sebastian Raschka & David Julian & John Hearty
Deep Learning in Python - LazyProgrammer
Python String swapcase()
Python Dictionary
Python Function Arguments