Python3 title() Method
Description
The Python title() method returns a "titlecased" string, that is, a string in which the first letter of every word is uppercase and all remaining letters are lowercase (see istitle())。
Syntax
Syntax of the title() method:
str.title();
Parameters
- NA。
Return Value
Returns a "titlecased" string, that is, the first letter of every word is uppercase.
Example
The following example shows how to use the title() function:
Example (Python 3.0+)
#!/usr/bin/python3
str
=
"
this is string example from runoob....wow!!!
"
(
str
.
title
(
)
)
The output of the above example is:
This Is String Example From Runoob....Wow!!!
Note that the first letter after a non-letter is also converted to uppercase:
Example (Python 3.0+)
#!/usr/bin/python3
txt
=
"
hello b2b2b2 and 3g3g3g
"
x
=
txt
.
title
(
)
(
x
)
The output is:
Hello B2B2B2 And 3G3G3G
Python3 Strings