str.isalpha()
Returns True when a string is not empty and every character is a letter, in any alphabet. Spaces and digits make it False.
str.isalpha()isalpha() returns True if the string has at least one character and all of them are letters. Letters from every alphabet count: "Zoë", "Αθήνα" and "東京" all pass.
Use it to check names, words in a game, or single characters while you loop through a text.
A common surprise: a space is not a letter, so a full name like "Ana Silva" gives False. Neither are hyphens or apostrophes, so check each word, or remove those characters first.
Return value
True or False.
Examples
1Simple checks
print("Maria".isalpha())
print("Zoë".isalpha())
print("abc123".isalpha())
print("".isalpha())True True False False
2A space is not a letter
name = "Ana Silva"
print(name.isalpha())
print(name.replace(" ", "").isalpha())
print(all(part.isalpha() for part in name.split()))False True True
3Count the letters in a sentence
text = "Hi! It's 2026."
letters = sum(1 for c in text if c.isalpha())
print(letters)5
4Keep only letters
messy = "p-y_t h0o!n"
print("".join(c for c in messy if c.isalpha()))python
Common mistakes
Rejecting real names
Names can contain spaces, hyphens and apostrophes. Remove the allowed marks before checking.
for name in ["Jean-Luc", "O'Neil", "Mary Ann", "R2D2"]:
core = name.replace("-", "").replace("'", "").replace(" ", "")
print(name, core.isalpha())Jean-Luc True O'Neil True Mary Ann True R2D2 False
Questions people ask
Does isalpha() accept accented letters?
Yes. é, ñ, ü and letters of other alphabets all count as letters.
How do I check for English letters only?
Add isascii(): text.isascii() and text.isalpha().
How do I allow letters and digits?
Use str.isalnum().