The title method
The title
method returns a string with the first character of each word in uppercase, and all other characters in lowercase.
Syntax
string.title()
Example
Let's apply the title
method to the following line:
txt = 'abcde'
print(txt.title())
Result of code execution:
'Abcde'
Example
Let's compare the application of the title
method and the capitalize
method:
txt = 'abc def'
print(txt.title())
print(txt.capitalize())
Result of code execution:
'Abc Def'
'Abc def'
See also
-
method
istitle
,
which checks the first character of a word for uppercase -
method
capitalize
,
which changes the first character of a string to uppercase -
method
upper
,
which returns all characters of a string in uppercase -
method
swapcase
,
which changes the case of characters to the opposite -
method
lower
,
which returns all lowercase characters -
method
isupper
,
which checks all characters in a string for uppercase -
method
islower
,
which checks the characters of a string for lowercase