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.
Headings of Contents
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.
The syntax of the string title function in Python.
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.
a = 'python' result = a.title() print(result)
The output will be:- Python
a = 'programming funda is education site.' for i in a.split(): print(i.title())
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)
My Name Is Alex, I Am 25 Years Old And My Email Id Is [email protected]
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
- String endswith() method
- String casefold() method
- String center() method
- String capitalize() method
- String count() method
- String index() method
- String format() method
- String isalpha() method
- String isidentifier() method
- String islower() method
- String isupper() method
For more information:- Click Here