Python string istitle() method
Python String istitle() Method
Description
istitle()
method checks if each space-delimited substring starts with an uppercase letter and the rest of the letters are lowercase. Non-alphabetic characters (numbers, symbols, etc.) are ignored.
Syntax
Below is the syntax of the istitle()
method −
var.istitle()
Parameters
None
Return Value
This method returns True if the string is a title-formatted string and has at least one character. For example, uppercase characters can only follow uncase characters, and lowercase characters can only follow cased characters. Otherwise, it returns False
.
Example
The following example demonstrates the use of the istitle()
method.
var = "Hello Python"
var1 = var.istitle()
print ("Original string:", var)
print ("Is it in title format?:", var1)
var = "HelloPython"
var2 = var.istitle()
print ("Original string:", var)
print ("Is it in title format?:", var2)
var = "Welcome To TutorialsPoint"
var3 = var.istitle()
print ("Original string:", var)
print ("Is it in title format?:", var3)
Running this program will produce the following output −
Original string: Hello Python
Is it title formatted?: True
Original string: HelloPython
Is it title formatted?: False
Original string: Welcome to TutorialsPoint
Is it title formatted?: False