![]() |
VOOZH | about |
The isalpha() method checks if all characters in a given string are alphabetic. It returns True if every character in the string is a letter and False if the string contains any numbers, spaces, or special characters.
Let’s start with a simple example of using isalpha()
True False
Explanation: The string s1 are contains only alphabetic characters, so isalpha() returns True but the string s2 contains non-alphabetic characters so isalpha() returns False
string.isalpha()
Parameter:
Return Type: Returns True if all characters in string are alphabetic (A-Z, a-z) and False otherwise.
False
Explanation: Since s contains a space which is not an alphabetic character, so isalpha() returns False.
False
Explanation: Here, s contains numbers, so isalpha() returns False.
False
Explanation: Since the string s contains the special character !, it is not purely alphabetic, so isalpha() returns False.