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:
Map to String Conversion in Java
Python break and continue
Deep Learning from Scratch - Building with Python form First Principles - Seth Weidman
Python Inheritance
Python Set union()
Python Dictionary keys()
Python Program to Print all Prime Numbers in an Interval
Python List sort()
Python String join()
Python type()
Python bytearray()
Python Multiple Inheritance
Python frozenset()
Python Program to Swap Two Variables
Python Program to Convert Decimal to Binary Using Recursion
Python String isnumeric()
Java Program to Permute All Letters of an Input String
Python if...else Statement
Java – Generate Random String
Python help()
Python *args and **kwargs
Convert String to Byte Array and Reverse in Java
Python Program to Reverse a Number
Python List Comprehension
Most commonly used String methods in Java
Node.js vs Python for Backend Development
Python eval()
Python map()
Python Set issubset()
Machine Learning Applications Using Python - Cases studies form Healthcare, Retail, and Finance - Pu...
Python Program to Convert Decimal to Binary, Octal and Hexadecimal
Python Program to Generate a Random Number