The istitle method

The istitle method checks the first character of each word in a string for uppercase. Nothing is passed to the method parameters. The method returns the Boolean values ​​True or False.

Syntax

pythonstring.istitle()

Example

Let's check if each word in a string starts with uppercase:

pythontxt = 'Abc Def'
print(txt.istitle())

Result of code execution:

pythonTrue

Example

Now let's change the case of the first character in the second word and check our string again:

pythontxt = 'Abc def'
print(txt.istitle())

Result of code execution:

pythonFalse

Example

Let's add numbers to the first word and check our string again using the istitle method:

pythontxt = '12abc Def'
print(txt.istitle())

Result of code execution:

pythonFalse

See also

  • method isupper,
    which checks all characters in a string for uppercase
  • method islower,
    which checks the characters of a string for lowercase
  • method upper,
    which returns all characters of a string in uppercase
  • method capitalize,
    which changes the first character of a string to uppercase
  • method casefold,
    which returns all unicode characters in lowercase
  • method lower,
    which returns all lowercase ASCII characters
  • method swapcase,
    which changes the case of characters to the opposite