String method

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.

BeginnerEvery example below runs in your browser. Change the code and press Run.

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

Pythoneditable
print("Maria".isalpha())
print("Zoë".isalpha())
print("abc123".isalpha())
print("".isalpha())
Output
True
True
False
False

2A space is not a letter

Pythoneditable
name = "Ana Silva"
print(name.isalpha())
print(name.replace(" ", "").isalpha())
print(all(part.isalpha() for part in name.split()))
Output
False
True
True

3Count the letters in a sentence

Pythoneditable
text = "Hi! It's 2026."
letters = sum(1 for c in text if c.isalpha())
print(letters)
Output
5

4Keep only letters

Pythoneditable
messy = "p-y_t h0o!n"
print("".join(c for c in messy if c.isalpha()))
Output
python

Common mistakes

Rejecting real names

Names can contain spaces, hyphens and apostrophes. Remove the allowed marks before checking.

Pythoneditable
for name in ["Jean-Luc", "O'Neil", "Mary Ann", "R2D2"]:
    core = name.replace("-", "").replace("'", "").replace(" ", "")
    print(name, core.isalpha())
Output
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().

Spotted a mistake on this page? Tell us