Python isalpha() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
String

Definition

In Python, isalpha() returns True when every character is a letter and the string is not empty.

It takes no arguments. Digits, spaces, and punctuation make it return False.

Syntax

Call isalpha on the string. Start with this line.

python
ok = text.isalpha()
CallWhat it does
"Hello".isalpha()Returns True.
"Hello World".isalpha()Returns False (space).

An empty string always returns False.

Library declarations
python
str.isalpha() → bool

Parameters

This method has no parameters.

Return Value

Return ValueDescription
boolTrue if all characters are letters.

Python Examples

Example 1 — Basic isalpha() Checks

See what passes and what fails.

python
samples = ["Python", "abc123", "Hi!", "a b", "", "café"]

for s in samples:
    print(repr(s), "→", s.isalpha())

How It Works

  1. Letters pass. "Python" is all alphabetic.
  2. Digits fail. Any digit in "abc123" returns False.
  3. Symbols and spaces fail. ! and spaces break the rule.
  4. Unicode letters can pass. "café" counts as letters.

Example 2 — Validate a Name Token

Allow only letters after trimming outer spaces.

python
def is_letter_token(text):
    cleaned = text.strip()
    return cleaned != "" and cleaned.isalpha()

print(is_letter_token("  Ada  "))
print(is_letter_token("Ada42"))
print(is_letter_token("   "))

How It Works

  1. Strip edges. Outer spaces are removed before the test.
  2. Require content. All-space input becomes "" → reject.
  3. isalpha decides. "Ada" passes; digits fail.
  4. Names with spaces. Full names need a different rule (split words, then check each).

Example 3 — isalpha vs isalnum

Same string, two different questions.

python
s = "abc123"

print("isalpha:", s.isalpha())
print("isalnum:", s.isalnum())
print("isdigit:", s.isdigit())

How It Works

  1. isalpha rejects digits. Needs letters only → False.
  2. isalnum allows the mix. Letters + digits → True.
  3. isdigit rejects letters. Needs digits only → False.
  4. Pick by rule. Pure names → isalpha; IDs → isalnum.

Frequently Asked Questions

It returns True if every character is a letter and the string is not empty.
False.
No. A space makes it False.
isalpha() requires letters only. isalnum() also allows digits.
Yes. Many non-ASCII letters can return True.

Next: isdecimal()

Check whether every character is a decimal digit.

isdecimal() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

9 people found this page helpful