
isalpha() Method –
isalpha() method returns True if all the characters of a string are alphabets and returns False if not.
Syntax –
string.isalpha()
Example –
In [1]: string1 = 'python'
In [2]: string1.isalpha()
Out[2]: True
In [3]: string2 = 'python3'
In [4]: string2.isalpha()
Out[4]: False
The second example contains a number along with the alphabets that is why it is False. If you want to check whether a string contains alphabets or numbers then we use isalnum() method.
Related Posts –
- Python String Method – Capitalize()
- Python String Method – title()
- Python String Method – center()
- Python String Method – count()
- Python String Method – startswith()
- Python String Method – endswith()
- Python String Method – find()
- Python String Method – index()
- Python String Method – isalnum()