Python 3 reference · String Methods
Python String isalpha() Method
Return True if every character is a letter (in any alphabet) and the string isn't empty. Spaces and digits return False.
Python 3 Since 3.0
Syntax
str.isalpha()
Return value
True or False.
Examples
for s in ["Python", "Py3", "naïve", "two words", ""]:
print(repr(s), s.isalpha())
Output
'Python' True 'Py3' False 'naïve' True 'two words' False '' False
name = "Mary Jane"
print(all(part.isalpha() for part in name.split()))
Output
True
Version history
| Version | Change |
|---|---|
| Python 3.0 | Added |
Related
str.isalnum()· Return True if every character is a letter or a digit and the string isn't empty.str.isascii()· Return True if the string is empty or every character is ASCII (code points 0–127).str.isspace()· Return True if every character is whitespace (spaces, tabs, newlines) and the string isn't empty.- Python Strings · tutorial