Python String title()

Python String.title() is used to convert this string into a title. title() method returns a new string with the first character of each word in the original string converted to uppercase.

In this tutorial, we will learn the syntax and examples for title() method of String class.

Syntax

The syntax to call title() method on string x in Python is

x.title()
ADVERTISEMENT

Examples

In the following program, we take a string 'sample title', and convert this string into title using title() method.

Example.py

x = 'sample title'
result = x.title()
print('Original String : ', x)
print('Result String   : ', result)
Try Online

Output

Original String :  sample title
Result String   :  Sample Title

Conclusion

In this Python Tutorial, we learned how to convert a string to title using title() method, with examples.