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

Get notified of the best deals on our WordPress themes.

You May Also Like
Python Comment Block / Python Multiline Comment

Python Comment Block

Table of Contents Hide Introduction to Python Comment BlockTypes of comments in PythonSingle-line commentsInline commentsMultiline commentsUsing Multiple Hashtags (#)Python docstringsSingle line docstringsMulti-line docstrings Comments are a piece of text in…
View Post
Python String Split()

Python String split()

Table of Contents Hide split() Syntaxsplit() Parameterssplit() Return ValueExample 1: How split() works in Python?Example 2: How split() works when maxsplit is specified? The Python String split() method is a…
View Post
Calculate Standard Error In R

Calculate Standard Error in R

Table of Contents Hide How to Calculate Standard Error in R?Using sd() methodUsing the standard error formulaUsing std.error() method from plotrix The standard error (SE) of a statistic is the standard deviation of its sampling…
View Post