Python String title() Method

The title() method returns a string where each word starts with an uppercase character, and the remaining characters are lowercase. If the word contains a number or a symbol, the first letter after that will be converted to upper case.

Syntax:

str.title()

Parameters:

None

Return Value:

Returns a string.

The title() method converts the first letter of each word in a string to the upper case and the rest in the lower case, as shown below.

Example: title()
>>> 'hello world'.title()
Hello World
>>> 'hELo wORld'.title()
Hello World
>>> mystr = 'TutorialsTeacher is a free tutorials website'
>>> mystr.title()
'Tutorialsteacher Is A Free Tutorials Website'

The numeric string and symbols are ignored. However, if an alphabet comes immediately after a number, then it converts it to uppercase, as shown below.

Example: title()
>>> '123456'.title()
'123456'
>>> '#1 harbour side'.title()
'#1 Harbour Side'
>>> '123abc'.title()
'123Abc'