Python String isalpha() Method

Determines whether the string contains alphabetic characters

Usage

The isalpha() method returns TRUE if the string is nonempty and all characters in it are alphabetic (a-z or A-Z). Otherwise, it returns FALSE.

Syntax

string.isalpha()

Basic Example

Example: Check if all characters in the string are alphabetic

S = 'abc'
x = S.isalpha()
print(x)    # True

String with Number/Special Character

The isalpha() method returns FALSE if at least one character is not alphabetic.

Example:

S = '123'
x = S.isalpha()
print(x)    # False
S = 'abc123'
x = S.isalpha()
print(x)    # False

even a space

S = 'abc xyz'
x = S.isalpha()
print(x)    # False

isalpha() on Empty String

The isalpha() method returns FALSE if the string is empty.

Example:

S = ''
x = S.isalpha()
print(x)    # False