Python isalpha() method
Description
The Python isalpha() method checks whether the string consists only of letters.
Syntax
Syntax of the isalpha() method:
str.isalpha()
Parameters
- None.
Return Value
Returns True if the string has at least one character and all characters are letters; otherwise, returns False.
Example
The following example demonstrates the isalpha() method:
Example
#!/usr/bin/python
# coding=utf-8
str = "example";
print str.isalpha();
str = "example Rookie Tutorial";
print str.isalpha();
str = "this is string example....wow!!!";
print str.isalpha();
# coding=utf-8
str = "example";
print str.isalpha();
str = "example Rookie Tutorial";
print str.isalpha();
str = "this is string example....wow!!!";
print str.isalpha();
The output of the above example is:
True False False
Other Extensions
Python String