The isalpha method

The isalpha method checks that a string consists only of letters. Nothing is passed to the method parameters. The method returns the Boolean values ​​True or False.

Syntax

pythonstring.isalpha()

Example

Let's check that the string consists only of letters:

pythontxt = 'abcade'
print(txt.isalpha())

Result of code execution:

pythonTrue

Example

Now let's say there are other symbols in the line:

pythontxt = 'abcade12'
print(txt.isalpha())

Result of code execution:

pythonFalse

See also

  • method isalnum,
    which checks if a string contains letters and numbers
  • method isdigit,
    which checks if a string contains only numbers
  • method isnumeric,
    which checks if a string contains only numbers
  • method isspace,
    which checks if a string contains only spaces