Python Reference Library →

Python String isalpha() Method – Check for Alphabetic Characters

Let’s look at string isalpha() method – check for alphabetic characters

  1. Notice

    isalpha() requires a nonempty string made entirely of Unicode letters; it is not limited to ASCII.

  2. Try

    Follow the example, change its sample, and compare what happens.

  3. Check

    Explain the result and test your understanding.

Watch how it works

Focus on how the names, objects, and calculations change. We’ll inspect the printed output in the next section.

Explore the idea

Follow the code and watch its state change. Guided simulation.

Code
Python
text = 'café'
result = text.isalpha()
print(result)
Live state

Top-level scope

text→Object 1
result→Object 2
Object 1 · str'café'Object 2 · boolTrue
This step

isalpha() requires a nonempty string made entirely of Unicode letters; it is not limited to ASCII.

Picture string isalpha() method – check for alphabetic characters

isalpha() requires a nonempty string made entirely of Unicode letters; it is not limited to ASCII.

Image brief

Alt text
A diagram for Python String isalpha() Method – Check for Alphabetic Characters. Instructions: text = 'café' result = text.isalpha() print(result). Displayed result: True. The final example bindings are text --> object 1 (str); result --> object 2 (bool). object 1: 'café'; object 2: True
Image generation prompt
Create a clean educational illustration for a Python programming lesson titled "Python String isalpha() Method – Check for Alphabetic Characters". Teaching focus: isalpha() requires a nonempty string made entirely of Unicode letters; it is not limited to ASCII. Depict exactly the relationships and labels in this reference diagram: EXAMPLE INSTRUCTIONS text = 'café' result = text.isalpha() print(result) | v DISPLAYED RESULT True FINAL BINDINGS text --> object 1 (str) result --> object 2 (bool) object 1: 'café' object 2: True Use a flat vector style, generous spacing, clear arrows and legible labels, with a restrained blue/teal palette on a plain background. The diagram must explain the programming idea accurately. Do not depict variables as boxes containing copied objects when they share a reference. Avoid mascots, decorative screenshots, logos, gradients and extra text. Landscape composition, approximately 3:2, suitable for a course card. Accessible description: A diagram for Python String isalpha() Method – Check for Alphabetic Characters. Instructions: text = 'café' result = text.isalpha() print(result). Displayed result: True. The final example bindings are text --> object 1 (str); result --> object 2 (bool). object 1: 'café'; object 2: True

Follow the execution

Choose a different sample input, then follow every step through to the output. Before revealing it, predict what the program will display.

Execution workspace

Choose a sample and follow its execution. Guided simulation.

Code
Python
text = 'café'
result = text.isalpha()
print(result)
Live state

Top-level scope

text→Object 1
result→Object 2
Object 1 · str'café'Object 2 · boolTrue
This step

The example has finished. Compare the final output with the values and references above.

Terminal
Output
True

What do you expect this program to print?

What does this example display?

text = 'café'
result = text.isalpha()
print(result)
What does this example display?
Choose one answer. You can try again.

Answer and explanation

True

Follow the printed values in order. The output is: True

Which explanation matches what you learned?

Which explanation matches what you learned?
Choose one answer. You can try again.

Answer and explanation

isalpha() requires a nonempty string made entirely of Unicode letters; it is not limited to ASCII.

isalpha() requires a nonempty string made entirely of Unicode letters; it is not limited to ASCII.

More examples and reference

Python String isalpha() Method

The isalpha() method in Python checks if all characters in a string are alphabetic (letters A-Z and a-z). It's useful for input validation, data filtering, and more.

Syntax

string.isalpha()

Parameters:

  • No parameters required.

Returns:

  • True – If all characters are alphabetic and the string is not empty.
  • False – If there are any non-alphabetic characters (numbers, spaces, symbols, etc.) or if the string is empty.

Example 1: All Letters

text = "Python"
print(text.isalpha())
True

Example 2: Contains Numbers

text = "Python3"
print(text.isalpha())
False

Example 3: Contains Spaces

text = "Hello World"
print(text.isalpha())
False

Example 4: Empty String

text = ""
print(text.isalpha())
False

Use Cases

  • Validating if a name contains only letters
  • Pre-checking strings before using them in word-based logic
  • Filtering out invalid words from a dataset

Note on Unicode Characters

isalpha() returns True for letters in other languages too. For example:

print("नमस्ते".isalpha())
True

Common Mistakes

  • Using it to check for alphanumeric strings (use isalnum() instead).
  • Expecting it to ignore spaces – it doesn't.

Interview Tip

isalpha() is commonly used in input sanitization and parsing problems in coding interviews and online judges.

Summary

  • isalpha() checks if all characters in the string are letters.
  • Returns False if there are spaces, digits, or symbols.
  • Returns False on an empty string.

Practice Problem

Ask the user to enter a name and print whether it is valid (contains only letters):

name = input("Enter your name: ")
if name.isalpha():
    print("Valid name!")
else:
    print("Invalid name. Please use only letters.")

What to remember

Connect what you noticed in the example with the idea below.

Remember

isalpha() requires a nonempty string made entirely of Unicode letters; it is not limited to ASCII.

Watch out for this idea

isalpha() recognizes only A–Z and a–z.

This is the misconception to avoid.

Reference checks are optional and do not count toward course progress.

    Reference library →