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 pass statement
Java – Reader to String
Python Matrices and NumPy Arrays
Java Program to Permute All Letters of an Input String
Machine Learning Mastery with Python - Understand your data, create accurate models and work project...
Format ZonedDateTime to String
Case-Insensitive String Matching in Java
String Hashing
Python Program to Sort a Dictionary by Value
Python Modules
Python Program to Convert Kilometers to Miles
Python Tuple
Count Occurrences of a Char in a String
Python Machine Learning Eqution Reference - Sebastian Raschka
Python Program to Display Powers of 2 Using Anonymous Function
Python Program to Iterate Over Dictionaries Using for Loop
Python Program to Make a Simple Calculator
Python bool()
Check If a String Is Numeric in Java
Python Set difference_update()
Python Generators
Convert String to Byte Array and Reverse in Java
Python Program to Get the Last Element of the List
Machine Learning Applications Using Python - Cases studies form Healthcare, Retail, and Finance - Pu...
Python Dictionary update()
How to Remove the Last Character of a String?
Python Program to Safely Create a Nested Directory
Python Program to Iterate Through Two Lists in Parallel
Python List remove()
Python String expandtabs()
How to Get Started With Python?
Adding a Newline Character to a String in Java