What does isalpha do in Python? str.isalpha() returns True when every character in a string is a letter and the string isn’t empty. A single space, digit or punctuation mark makes it False:
"Austin".isalpha() # True
"New York".isalpha() # False (the space)
"".isalpha() # False (empty)
I tested each example on Python 3.12.5, including accented and non-English letters.
You’ll see the basic rules, how to validate names that contain spaces or hyphens, how isalpha() compares with isalnum() and isdigit(), counting and filtering letters, and an input check.
How isalpha() works in Python
It checks every character you pass, and it needs at least one. It understands Unicode, so letters with accents and letters from other alphabets count too:
tests = ["Austin", "New York", "Route66", "", "José", "naïve", "abc!", "ÉCOLE", "東京"]
for t in tests:
print(f"{t!r:<12} isalpha() -> {t.isalpha()}")
Output:
'Austin' isalpha() -> True
'New York' isalpha() -> False
'Route66' isalpha() -> False
'' isalpha() -> False
'José' isalpha() -> True
'naïve' isalpha() -> True
'abc!' isalpha() -> False
'ÉCOLE' isalpha() -> True
'東京' isalpha() -> True

If you only want the English letters A to Z, you can combine it with isascii(), as shown further down.
How do you validate names with isalpha()?
Your users’ real names often fail a plain isalpha() check: “Mary Ann”, “O’Brien” and “Smith-Jones” are all valid. Split on the allowed separators and check each piece:
import re
def valid_name(name):
"""Letters plus single spaces, hyphens or apostrophes between them."""
parts = re.split(r"[ '\-]", name.strip())
return bool(name.strip()) and all(part.isalpha() for part in parts)
for name in ["Mary Ann", "O'Brien", "Smith-Jones", "Ann3", " ", "José Luis", "Bob--Lee"]:
print(f"{name!r:<14} plain isalpha: {name.isalpha()!s:<5} valid_name: {valid_name(name)}")
Output:
'Mary Ann' plain isalpha: False valid_name: True
"O'Brien" plain isalpha: False valid_name: True
'Smith-Jones' plain isalpha: False valid_name: True
'Ann3' plain isalpha: False valid_name: False
' ' plain isalpha: False valid_name: False
'José Luis' plain isalpha: False valid_name: True
'Bob--Lee' plain isalpha: False valid_name: False

isalpha() rejects three real names; the validator accepts them but still rejects digits and doubled hyphens.The split uses a regular expression; for more on those, see Python replace with regular expression.
isalpha vs isalnum vs isdigit vs isnumeric
You’ll notice these methods look alike, but they answer different questions. Digits, special numeric characters and non-ASCII letters are where they disagree:
samples = ["abc", "abc123", "123", "½", "²", "Café", " "]
print(f"{'text':<10}{'isalpha':<9}{'isalnum':<9}{'isdigit':<9}{'isnumeric':<11}{'isascii'}")
for s in samples:
print(f"{s!r:<10}{s.isalpha()!s:<9}{s.isalnum()!s:<9}{s.isdigit()!s:<9}{s.isnumeric()!s:<11}{s.isascii()}")
Output:
text isalpha isalnum isdigit isnumeric isascii
'abc' True True False False True
'abc123' False True False False True
'123' False True True True True
'½' False True False True False
'²' False True True True False
'Café' True True False False False
' ' False False False False True

| Method | True when every character is |
|---|---|
isalpha() | A letter |
isalnum() | A letter or a number |
isdigit() | A digit, including superscripts like ² |
isnumeric() | Any numeric character, including ½ |
isascii() | ASCII (true for the empty string too) |
For numbers specifically, see the isdigit() method in Python.
Counting and filtering letters in a string
Because True counts as 1, sum(ch.isalpha() for ch in text) counts letters. A join with the same check strips everything else:
review = "Great coffee!!! Rated 5/5 by 120 customers in Seattle, WA."
letters = sum(ch.isalpha() for ch in review) # True counts as 1
only_letters = "".join(ch for ch in review if ch.isalpha())
words = [w.strip(".,!") for w in review.split() if w.strip(".,!").isalpha()]
print("letters:", letters)
print("letters only:", only_letters)
print("alphabetic words:", words)
print("ASCII letters only:", "".join(ch for ch in "Café Olé" if ch.isascii() and ch.isalpha()))
Output:
letters: 38
letters only: GreatcoffeeRatedbycustomersinSeattleWA
alphabetic words: ['Great', 'coffee', 'Rated', 'by', 'customers', 'in', 'Seattle', 'WA']
ASCII letters only: CafOl
These one-liners are generator expressions; see what yield does in Python for how they work underneath.
Using isalpha() to validate user input
I use it most for rejecting input that should be words only. Removing spaces first lets multi-word answers like “san diego” through:
while True:
city = input("Enter a city name (letters only): ").strip()
if city.replace(" ", "").isalpha():
print(f"Thanks! Shipping to {city.title()}.")
break
print(" Please use letters and spaces only.")
Output:
Enter a city name (letters only): Denver 80202
Please use letters and spaces only.
Enter a city name (letters only): 12345
Please use letters and spaces only.
Enter a city name (letters only): san diego
Thanks! Shipping to San Diego.

The loop pattern is the same one used in infinite loops in Python: repeat until the input passes, then break.
More string method guides:
- Check if a string contains a substring
- Convert an int to a string
- count() in Python strings
- Capitalize the first letter of each word
Frequently asked questions
What does isalpha do in Python?
It returns True if a string is non-empty and every character is a letter, and False otherwise.
Why does isalpha return False for a sentence?
Spaces and punctuation aren’t letters. Use text.replace(" ", "").isalpha() or check each word.
Does isalpha work with accented letters?
Yes. It follows Unicode, so letters like é, ñ and ü count as alphabetic.
How do I check for English letters only?
Combine both checks: s.isascii() and s.isalpha().
What does isalpha return for an empty string?
False, because there has to be at least one character.
Where is isalpha documented?
See str.isalpha in the Python docs.

Bijay Kumar is a 13-time Microsoft MVP with more than 18 years in software development, and the founder of Python Guides and TSinfo Technologies. He started out building .NET and SharePoint solutions at HP, TCS and KPIT before moving into Python, machine learning and AI, and he also builds web apps with TypeScript and React. He writes the tutorials here himself, and every example is run before publishing so you see the real output. More about Bijay · Microsoft MVP profile · LinkedIn