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.
Fundamentals
Definition and Usage
In Python, isalpha() inspects each character in a string. If every character is a letter (a–z, A–Z, 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.
Foundation
📝 Syntax
The isalpha() method takes no parameters:
python
string.isalpha()
Syntax Rules
string — any valid Python str object.
Return value — True 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.
Reference
↩ 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.
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)
📤 Output:
'Mari' → Name accepted.
'Mari123' → Use letters only (no spaces or numbers).
'Mari Selvan' → Use letters only (no spaces or numbers).
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.
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.
Important
📝 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.
Wrap Up
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.
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
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about isalpha()
Use these points when validating strings in Python.
5
Core concepts
✅01
Letters Only
No digits or symbols.
Purpose
🔢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.