In python, the string title() method is useful to convert the first letter of every word in the given string to uppercase. If the first letter of the word is a number or symbol, it will convert the next letter to uppercase.
Following is the pictorial representation of the string title()
method functionality in python.
If you observe the above diagram, we are trying to convert the given string “hi guest hi
” to title case using the title
function in python.
Following is the syntax of defining a string title method in python.
The python title()
method will not accept any parameters.
Following is the example of converting the first letter of every word in the given string to uppercase using the string title()
method in python.
If you observe the above example, we are converting the first letter of every word in the given string to uppercase using the title()
method.
When you execute the above python program, you will get the result as shown below.
This is how you can use the string title() method in python to convert the given strings to title case based on your requirements.