How to Use String istitle() Method in PythonPython Basics


The istitle() method checks if a string is titlecased. For titlecased string, the first letter of each word should be capitalized.

Example

#!/usr/bin/python3
# -*- coding: UTF-8 -*-

s = 'Have A Nice Day!'
print(s.istitle())

s = 'Have a nice day!'
print(s.istitle())

Output:

True
False

Syntax

string.istitle()

Parameters

The method doesn’t take any parameters.

Return Value

It returns True or False, depending on whether the first letter of each word is capitalized.

© 2024 Learnwithgpt.org, all rights reserved. Privacy Policy | Contact Us