Python isalpha() Method

Beginner
⏱️ 7 min read
📚 Updated: Jul 2026
🎯 5 Examples
String Methods

What You’ll Learn

The isalpha() method returns True when every character in a string is a letter and the string is not empty. It is the go-to check when you need letters only—no digits, spaces, or punctuation—such as validating a first name or a city written in plain text.

01

Letters Only

No digits allowed.

02

Returns bool

True or False result.

03

No Arguments

Call directly on str.

04

Empty = False

Zero-length fails check.

05

Name Checks

Validate text fields.

06

vs isalnum()

Letters vs letters+digits.

Definition and Usage

In Python, isalpha() inspects each character in a string. If every character is a letter (az, AZ, or Unicode letters) and the string has at least one character, it returns True. Otherwise it returns False. For example, "HelloWorld".isalpha() is True, but "Hello123".isalpha() is False because of the digits.

💡
Beginner Tip

isalpha() means “is alphabetic”—letters only. Spaces between words, hyphens in names, and numbers all cause False. For letters and digits together, use isalnum() instead.

📝 Syntax

The isalpha() method takes no parameters:

python
string.isalpha()

Syntax Rules

  • string — any valid Python str object.
  • Return valueTrue if all characters are letters and the string is non-empty; otherwise False.
  • No arguments — passing arguments raises TypeError.
  • Read-only — the original string is never modified.
  • Unicode — letters from other languages (like é, ñ, or ü) count as letters in Python 3.

↩ Return Value

isalpha() always returns a boolean—never an integer or string. It returns True only when the string contains one or more characters and every character is a letter. It returns False for empty strings, strings with digits, and strings with any space, symbol, or punctuation.

python
print("HelloWorld".isalpha())  # True
print("Hello123".isalpha())    # False (digits)
print("".isalpha())             # False (empty)
print("Hello World".isalpha()) # False (space)
print("Café".isalpha())         # True (Unicode letter é)

⚡ Quick Reference

ExpressionResult
"HelloWorld".isalpha()True
"Hello123".isalpha()False (digits)
"".isalpha()False (empty)
"Hello World".isalpha()False (space)
"Python!".isalpha()False (punctuation)
Basic
text.isalpha()

True or False

Validate
if name.isalpha():

Letters-only guard

Strip first
text.strip().isalpha()

Ignore edge spaces

Compare
"abc123".isalnum()

Letters + digits check

Examples Gallery

Run these examples in any Python 3 interpreter. Each one shows a common validation scenario.

📚 Getting Started

Check whether a string contains only letters.

Example 1 — Basic isalpha()

A string with letters only passes the check.

python
text = "HelloWorld"
result = text.isalpha()

print("Text:  ", text)
print("Result:", result)

How It Works

  • Every character in "HelloWorld" is a letter.
  • The string is non-empty, so isalpha() returns True.
  • Uppercase and lowercase letters both count as alphabetic.

Example 2 — Digits Make It False

Even one digit causes isalpha() to return False.

python
text = "Hello123"
result = text.isalpha()

print("Text:  ", text)
print("Result:", result)

How It Works

The digits 123 are not letters. If you need letters and digits, use isalnum() instead.

📈 Practical Patterns

Edge cases, name validation, and comparisons with related methods.

Example 3 — Empty String and Special Characters

See how isalpha() handles empty strings, spaces, and punctuation.

python
samples = ["", "Python", "Hello World", "Café", "Hello!"]

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

How It Works

  • Empty strings always return False.
  • Spaces and punctuation break the alphabetic-only rule.
  • Unicode letters like é in "Café" are treated as letters in Python 3.

Example 4 — Validating a First Name

Use isalpha() when a field must contain letters only—no spaces or numbers.

python
def is_valid_first_name(name):
    cleaned = name.strip()
    if not cleaned:
        return False, "Name cannot be empty."
    if not cleaned.isalpha():
        return False, "Use letters only (no spaces or numbers)."
    return True, "Name accepted."

for candidate in ["Mari", "Mari123", "Mari Selvan"]:
    ok, message = is_valid_first_name(candidate)
    print(repr(candidate), "→", message)

How It Works

For full names with spaces, isalpha() alone is too strict. Split the name into parts or use a custom validation rule.

Example 5 — isalpha() vs isalnum() vs isdigit()

These three methods test different character rules.

python
text = "Hello123"

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

print()
print("Hello".isalpha(), "Hello".isalnum(), "Hello".isdigit())
print("12345".isalpha(), "12345".isalnum(), "12345".isdigit())

How It Works

  • isalpha() requires all characters to be letters.
  • isalnum() allows letters and digits together.
  • isdigit() requires all characters to be digits.

🚀 Common Use Cases

  • First-name validation — ensure a single-word name contains letters only.
  • City or country codes — verify alphabetic text fields in forms.
  • Data cleaning — flag rows where a text column contains unexpected digits or symbols.
  • Game logic — check that a player’s move input is alphabetic before processing.
  • Teaching exercises — introduce string validation methods with a simple True/False result.

🧠 How isalpha() Works

1

Python reads the string

You call isalpha() on a str object—literal or variable.

Input
2

Each character is checked

Python tests whether every character is a letter. If the string is empty, the result is immediately False.

Scan
3

Boolean result is returned

True if all are letters; False if any digit, symbol, space, or empty string.

Result
=

Validation complete

Use the boolean in conditionals to accept or reject input.

📝 Notes

  • Digits, spaces, punctuation, and symbols all cause False.
  • An empty string "" always returns False—there must be at least one letter.
  • Unicode letters (like é, ñ, or ü) count as letters in Python 3.
  • isalpha() does not check string length—combine it with len() for min/max rules.
  • Store the result in a variable if you need to use it multiple times on the same string.

Conclusion

The isalpha() method is a simple, readable way to check whether a string contains only letters. It returns a clear boolean result, which makes it ideal for validating names, text fields, and other input that should be purely alphabetic.

Remember that digits and spaces fail the check, empty strings return False, and isalnum() is the better choice when numbers are allowed.

💡 Best Practices

✅ Do

  • Use isalpha() for single-word, letters-only fields
  • Call strip() before validating user input
  • Combine with len() for minimum/maximum length rules
  • Use isalnum() when digits should be allowed
  • Give clear error messages when validation fails

❌ Don’t

  • Use isalpha() for full names with spaces
  • Assume an empty string returns True
  • Pass arguments to isalpha()
  • Confuse isalpha() with isalnum()
  • Rely on it for complex format rules—use regex when needed

Key Takeaways

Knowledge Unlocked

Five things to remember about isalpha()

Use these points when validating strings in Python.

5
Core concepts
🔢 02

True / False

Boolean return only.

Return
🛠 03

Zero Arguments

s.isalpha()

Syntax
👤 04

Name Checks

Single-word fields.

Use case
05

Empty = False

No chars fails check.

Edge case

❓ Frequently Asked Questions

isalpha() returns True if every character in the string is a letter and the string is not empty. It returns False if the string contains digits, spaces, punctuation, symbols, or has no characters at all.
string.isalpha(). It takes no arguments and returns a boolean (True or False).
It returns False. An empty string has no alphabetic characters, so isalpha() is always False for "".
No. Digits are not letters, so "Hello123".isalpha() returns False. Use isalnum() if you need to allow both letters and digits.
isalpha() requires all characters to be letters only. isalnum() allows letters and digits together. For example, "Hello".isalpha() is True, but "Hello123".isalpha() is False while "Hello123".isalnum() is True.
No. isalpha() only inspects the string and returns a boolean. The original string stays unchanged.

Explore More Python String Methods

Continue with isdecimal(), isdigit(), and the rest of the string method reference.

Next: isdecimal() →

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.

16 people found this page helpful