Python String title() Method
Example
Capitalize the first letter of each word:
txt = "Welcome to my world" x = txt.title() print(x)
Definition and Usage
The title() method returns a string where the first character of each word is uppercase. For example, a title.
If a word contains numbers or symbols, the first letter after them will be converted to uppercase.
Syntax
string.title()
Parameter Value
No parameters.
More Examples
Example
Capitalize the first letter of each word:
txt = "Welcome to my 2nd world" x = txt.title() print(x)
Example
Please note that the first letter after a non-letter will be converted to uppercase:
txt = "hello d2d2d2 and 5g5g5g" x = txt.title() print(x)