isalpha() method for the string data type to check if a specified string consists of completely alphabet characters. Alphabet characters are from a to z and from A to Z. Both lowercase and uppercase characters are assumed as alphabet characters.
isalpha() Method Syntax
isalpha() method can be called on string types and has the following syntax and return value. There is no need to import any Python module in order to use isalpha() method. It is directly provided by string values and string variables.
- STRING is the string value or variable we wan to check for the alpha characters.
- The return type is boolean where is the STRING consist of only alpha characters it will return TRUE and there is single or multiple non-alpha characters it will return FALSE.
Before using the isalpha() method lets list the alpha or alphabet characters below. We can see that there is no number, sign or space in alphabet characters.
Actually listing the non-alpha characters are hard because except alphabete characters evey character is non-alpha characters. But we will list some well known non-alpha characters.
Lets make some examples with the isalpha() method. Below we will provide some string values or string variables and check if they are completely consist of alpha characters or contain any non-alpha characters.
"abc".isalpha() "abc123".isalpha() "abcABC".isalpha() "Iampythontect".isalpha() "I am pythontect".isalpha() "I . am ! pythontect".isalpha() "123456".isalpha() a = "abc" a.isalpha() b = "abc123" b.isalpha()
Is Space Alpha Character?
You may ask that is the space character is an alpha character because it is not a number or a sign. But the question to identify an alpha character is very simple. Are there any alphabet that provides the space as a character. No , space is not an alpha character and strings with a space will return false for the isalpha() method.
Is Tab Alpha Character?
Tab is similar to the space character where multiple spaces are used to create a tab. But as stated in the space character explanation the tab is not provided by any alphabet and tab is not an alpha character.