How Can We Help?
In this tutorial, We will explain how to use Python string title() method with basic syntax and many examples for better understanding.
How to Convert String to Title Case in Python? To convert a String to Title Case in Python, we use the title() method. The title method in Python returns the “title cased” version of the string which means all the words will start with uppercase and the remaining characters of each word will be in lowercase.
Syntax:
<string_value/string_variable>.title()
Input Parameters:
- string_value / String variable : The string that we want to convert to the title case.
Example
msg= 'welcome to python with oraask'
print('Title : ',msg.title())
Output of example
Title : Welcome To Python With Oraask
In the above example, all the words of the string variable ‘msg’ is title cased by msg.title(), and the output shows as ‘ Welcome To Python With Oraask’
In this tutorial, you have learned the string title() method in Python. And how to Capitalize the first character of a given string.
Hopefully, it was clear and concise.
If you have an inquiry or doubt, don’t hesitate to leave them in a comment. We are waiting for your valuable feedback.
Similar Python Formatting Methods:
- capitalize() : It capitalizes the first character of the String.
- center() : It returns a space-padded string with the original string centered to a total of width columns.
- swapcase() : It inverts the case of all the characters in a string.
- lower() : It converts all the characters of a string to lowercase.
- upper() : It converts all the characters of a string to uppercase.
- rstrip() : It removes particular character of a string from right side.
- lstrip() : It removes particular character of a string from left side.
- strip(chars) : It removes particular characters of a string from left and right side.
- ljust() : It returns an original string with a filled specific character or space at the left side of the string value to justify the string’s new length (width).
- rjust() : It returns an original string with a filled specific character or space at the right side of the string value to justify the string’s new length (width).
- zfill() : It returns an original string value with filled zero at the left side of the string value to justify the string’s new length (width).
Related Articles
Python String – Mastering By Practical Examples (Comprehensive Guide)
Python Tutorials List:
- Python tutorials list : access all python tutorials.