Python String Method – title()

Spread the love

title() method –

The title method capitalizes the first character of each word in a string.

Syntax –

string.title()

Example –

In [1]: s1 = "hi, how are you doing?"

In [2]: s1.title()
Out[2]: 'Hi, How Are You Doing?'

In [3]: s2 = "I am doing FINE"

In [4]: s2.title()
Out[4]: 'I Am Doing Fine'

The title method does not change the original string. It remains as it is.

In [5]: s1
Out[5]: 'hi, how are you doing?'

In [6]: s2
Out[6]: 'I am doing FINE'

Related Posts –

  1. Python String method – Capitalize()

Rating: 1 out of 5.

Leave a Reply