In this section, we will learn what String isalpha() method is and how to use it in Python.
What is String isalpha() Method in Python?
The Python string isalpha() method is used to check and see if the target string value only contains alphabet characters (a-z).
If that was the case, then this method will return the value True.
But if the string contained even one non-alphabet characters like (!@#$%^&*(white-space)(0-9) then return value of this method will be False.
Python String isalpha() Method Syntax:
String isalpha() Method Parameter
The method does not take an argument.
String isalpha() Method Return Value
The return value of this method is of type boolean.
The value True means the characters in the string are all alphabet letters.
The value False means there’s at least one non-alphabet character in the string.
Also, an empty string will cause this method to return the value False.
Example: using python string isalpha() method
s1= "THIS IS A SENTENCE" s2 = "Hello" s3 = "@# 122" print(s1.isalpha()) print(s2.isalpha()) print(s3.isalpha())
False True False