Python String istitle Method

The Python method istitle checks whether a string is formatted in title case, returning True if it is, and False if it is not.

Syntax of Python String istitle Method

It has the following syntax:

Example

istitle()

Parameters

No parameter is required.

Return

It returns either True or False.

Different Examples for Python String istitle Method

Let’s explore a few examples of the istitle method to grasp its capabilities.

Example 1

This is a straightforward illustration to comprehend the Python String istitle Method.

Example

# Python istitle() method example

# Variable declaration

str = "Welcome To Example"

# Calling function

str2 = str.istitle()

# Displaying result

print(str2)

Example 2

Let's consider another example to illustrate the functionality of the Python String istitle Method.

Example

# Python istitle() method example

# Variable declaration

str = "Welcome To Example" # True

# Calling function

str2 = str.istitle()

# Displaying result

print(str2)

str = "hello logicpractice"    # False

str2 = str.istitle()

print(str2)

Output:

Output

True

False

Example 3

Let's consider an example to illustrate the functionality of the Python String istitle method.

Example

# Python istitle() method example

# Variable declaration

str = "ab cd ef"

if str.istitle() == True:

    print("In title case")

else:

    print("Not in tit0le case")

str = "Ab Cd Ef"

if str.istitle() == True:

    print("In title case")

else:

    print("Not in title case")

str = "1b 2d 3f"

if str.istitle() == True:

    print("In title case")

else:

    print("Not in title case")

Output:

Output

Not in title case

In title case

Not in title case

Input Required

This code uses input(). Please provide values below: