In Python, the isalpha() method returns true if all the string characters are alphabets. Otherwise, It returns “False.”
The syntax of the method is: str.isalpha()
Key Points :
• There are no isalpha() function parameters.
• Returns true only if all string characters are alphabets (both upper and lower-case).
• One point to remember is that white space is not an alphabet; thus, if the string includes white space, the method returns false for that string.
We’ll be covering the following topics in this tutorial:
Return Value from isalpha()
The isalpha() returns:
• True if all string characters are alphabets (can be both lowercase and uppercase).
• Where there is no alphabet in a string, the string would return false if there are unique characters or numerical characters.
Below is the python program to demonstrate the isalpha() function:
str = "OnlineEducation"; # No space & digit in this string print (str.isalpha()) str = "The Best Learning Resource for Online Education"; print (str.isalpha())
When we run above the program, the outcome is as follows:
True
False
Working of isalpha()
Developer = "DineshThakur" if Developer.isalpha() == True: print("All characters are alphabets") else: print("All characters are not alphabets.")
When we run above the program, the outcome is as follows:
All characters are alphabets
Below are several other functions that we can use to work with string in Python 3