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

pythonstring.title()

Example

Let's apply the title method to the following line:

pythontxt = 'abcde'
print(txt.title())

Result of code execution:

python'Abcde'

Example

Let's compare the application of the title method and the capitalize method:

pythontxt = 'abc def'
print(txt.title())
print(txt.capitalize())

Result of code execution:

python'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