Easy Tutorial
❮ Python Os File Methods Python Func Open ❯

Python3 title() Method

Python3 String


Description

The Python title() method returns a "titlecased" string, meaning all words start with an uppercase letter and the remaining letters are lowercase (see istitle()).

Syntax

Syntax for the title() method:

str.title();

Parameters

Return Value

Returns a "titlecased" string, where the first letter of all words is converted to uppercase.

Example

The following example demonstrates the use of the title() function:

Example (Python 3.0+)

#!/usr/bin/python3

str = "this is string example from tutorialpro....wow!!!"
print (str.title())

The output of the above example is:

This Is String Example From Tutorialpro....Wow!!!

Note that the first letter after a non-alphabet character will be converted to uppercase:

Example (Python 3.0+)

#!/usr/bin/python3

txt = "hello b2b2b2 and 3g3g3g"
x = txt.title()
print(x)

The output is:

Hello B2B2B2 And 3G3G3G

Python3 String

❮ Python Os File Methods Python Func Open ❯