Menu Close

Python String title() Method

Python string title

In this article, you will learn about the Python string title() method to convert each character of the word into upper case. Python string title() method is used when you want to work with strings in python.

In the previous tutorial, we have seen the Python string swapcase function to convert lower case to upper case and vice versa.

Python string title() method

Python title function is a string function in Python that is used to convert each character of each word in upper case. It does not require any parameter and returns a new string after conversion.

Syntax

The syntax of the string title function in Python.

string.title()

Return Value

The title function in Python returns a new string with the converted character of each word in uppercase.

Python string title example

Here we will take some examples to understand the title function in python.

Example 1:

a = 'python'
result = a.title()
print(result)

The output will be:- Python

Example 2

a = 'programming funda is education site.'
for i in a.split():
    print(i.title())

Output

Programming
Funda
Is
Education
Site.

Convert the string to the title which contains an integer

Sometimes we want to convert a string to a title case that contained an integer as well, In that case, title() will work perfectly and it will give you a perfect result as expected. As you can see the below example.

string = "My name is alex, I am 25 years old and my email id is [email protected]"
result = string.title()
print(result)

Output

My Name Is Alex, I Am 25 Years Old And My Email Id Is [email protected]

Conclusion

In this tutorial, You have learned the Python string title() method to convert each character of each word in the upper case. Using the title function in python, you can convert each character of each word into upper case.

I hope, You found this tutorial helpful. If you like this article, please share it with your friends who want to learn Python programming.


Other string methods

For more information:- Click Here


Python String islower() Method
Python String partition() Method

Related Posts