str.isalpha()

Check that a string contains only letters — Unicode-aware, and False on empty.

String methodPython 1.0+Live demo
Common call
if name.isalpha():
Returns
True or False
Replaces
a manual loop of `if not ch.isalpha(): return False`
Watch out
empty string → False; spaces and digits both break it
str.isalpha()
bool

Demo

Live evaluation
Try:
Inputs
stringstrthe string to test
Output
'hello'.isalpha()
True

isalpha() returns True only when EVERY character is alphabetic AND the string is not empty. Alphabetic means letters from any script — Latin, Cyrillic, Greek, CJK — as classified by the Unicode standard. Digits, spaces, punctuation, and emojis all break it. The empty string returns False by convention (same as isdigit).

Common patterns

Validate a name-shaped input
Quick sanity check before deeper validation.
if not name.isalpha():
    raise ValueError("letters only")
Composite check
Combine with isdigit for "letters or digits, but no punctuation".
if s.isalnum() and not s.isdigit():
    ...    # has at least one letter
Strip and check
Real names have spaces — strip first if you want to allow them.
if all(part.isalpha() for part in name.split()):
    ...

Examples

1. All letters
"hello".isalpha()
Returns
True
2. Mixed with digits
"hello123".isalpha()
Returns
False
3. Space breaks it
"hello world".isalpha()
Returns
False
4. Unicode accents
"café".isalpha()
Returns
True
5. Cyrillic
"Привет".isalpha()
Returns
True
6. Empty is False
"".isalpha()
Returns
False
7. Punctuation breaks
"don\'t".isalpha()
Returns
False

Pitfalls

1. Empty string returns False, not True
A common surprise — you might expect "all zero characters are letters" to be vacuously true. Python defines it the other way: isalpha requires at least one character AND every one must be a letter.
Wrong expectation
"".isalpha()
False
Read the contract
"".isalpha()   # always False
"".isdigit()   # always False
"".isspace()   # always False
documented behaviour
2. Spaces are NOT alphabetic
A single space in a name breaks isalpha. Split first if multi-word input is legitimate.
Multi-word fails
"John Smith".isalpha()
False # the space
Per word
all(p.isalpha() for p in "John Smith".split())
True
3. Digits are NOT alphabetic
For "letters or digits" use isalnum instead. Numeric-looking letter forms (Roman numerals, superscripts) can be surprising — they may pass isnumeric but not isdigit.
Mixed fails
"user1".isalpha()
False
Use isalnum
"user1".isalnum()
True
4. Unicode "letters" include scripts you may not expect
isalpha returns True for any character Unicode classifies as a letter — Chinese ideographs, Arabic, Devanagari, and even some symbols. If you meant ASCII letters only, filter explicitly.
Too permissive
"漢字".isalpha()
True # CJK ideographs pass
ASCII only
name.isascii() and name.isalpha()
True only for ASCII letters

When to use

Use it
  • Sanity-checking that a token looks like a word
  • Combined with .split() for word-by-word validation
  • Composing with isalnum, isdigit, isspace for finer checks
  • Filtering tokens in a lexer / tokenizer
Reach for something else
  • Allowing spaces or punctuation → split first, or use a regex
  • ASCII-only validation → combine with .isascii()
  • Numeric content allowed → isalnum instead
  • Rich validation (length, format) → use a validator library or regex

Notes

Complexity
O(n) — one linear scan
Return
bool — True or False
CPython impl
Objects/unicodeobject.c :: unicode_isalpha
Memory
No allocation
Thread-safe
Yes — strings are immutable

FAQ

Python defines the empty case as False: isalpha requires at least one character. It mirrors the isdigit / isspace / isalnum family — all False on the empty string.

History

1.0
isalpha() has been part of str since Python 1.0.
3.0
Full Unicode support — accepts letters from any script per Unicode categorization.