Conversion of First Character of Each Word of a String to Uppercase in Python
In Python, you can convert the first character of each word of a string to uppercase using the str.title()
method.
Converting the first character of each word of a string to uppercase using 'str.title()' method
1. Create a variable named str_variable
and assign string value "python iS A proPramming language."
to the variable.
2. Apply the title()
method to the string variable str_variable
. This method converts the first character of each word of a string to uppercase. Store the result in a new variable called title_string
and get the output using print() function.
Please take a closer look at the following example:
Example of using title() method
Output of the above example
Python Is A Programming Language.