Python String title()

The Python String title() method is a built-in function that returns a string where the first character of each word is uppercase. It is also called a title case string.

In this article, we will learn about the Python String title() method with the help of examples.

title() Syntax

The Syntax of title() method is:


title() Parameters

The title() method does not take any parameters.

title() Return Value

The title() method returns the title cased version of a string. The first character of each word in a string is capitalized.

Note: The first letter is capitalized if it's a valid letter. In the case of digits or numbers, the conversion to uppercase will not happen.

Example 1: How Python title() works?

text = "Welcome to python programming, itsmycode"

text = "5 times 4 is = to 20 "


Welcome To Python Programming, Itsmycode
5 Times 4 Is = To 20 

Example 2: title() method in case of number and apostrophes

The presence of digits or number before the word will not affect the working of the function. The character after the digit is considered as the first character.

In case of apostrophes the title() capitalizes the first letter and the letter after apostrophes as well.

# incase the of numbers or digits at the beginning
text = "20dollars is the cost of Python programming book"

# in case of apostrophes
text = "it's python's interpreter"


20Dollars Is The Cost Of Python Programming Book
It'S Python'S Interpreter
Leave a Reply

Your email address will not be published.

Sign Up for Our Newsletters

Subscribe to get notified of the latest articles. We will never spam you. Be a part of our ever-growing community.

You May Also Like
Python String Swapcase()

Python String swapcase()

Table of Contents Hide swapcase() Syntaxswapcase() Parametersswapcase() Return ValueExample: Python Program to change the case of a given string Python string swapcase() method is a built-in function that converts all…
View Post
Python String Startswith()

Python String startswith()

Table of Contents Hide startswith() Syntaxstartswith() Parameterstartswith() Return ValueExample 1: startswith() Without start and end ParametersExample 2: startswith() With start and end ParametersPassing Tuple to startswith() Python String startswith() method…
View Post