Python3 title() Method
Description
The Python title() method returns a "title-cased" string, meaning the first letter of all words is converted to uppercase and the remaining letters are lowercase (seeistitle())。
Syntax
Syntax of the title() method:
str.title();
Parameters
- NA。
Return Value
Returns a "title-cased" string, meaning the first letter of all words is converted to uppercase.
Examples
The following example demonstrates how to use the title() function:
Example (Python 3.0+)
#!/usr/bin/python3
str = "this is string example from example....wow!!!"
print (str.title())
The output of the above example is:
This Is String Example From Example....Wow!!!
Note that the first letter after a non-letter character will be converted to uppercase:
Example (Python 3.0+)
#!/usr/bin/python3
txt = "hello b2b2b2 and 3g3g3g"
x = txt.title()
print(x)
The output result is:
Hello B2B2B2 And 3G3G3G
Other Extensions
Python3 Strings