You can use str.isalpha().
For example:
s = 'a123b'
for char in s:
print(char, char.isalpha())
Output:
a True
1 False
2 False
3 False
b True
Answer from rainer on Stack OverflowW3Schools
w3schools.com › python › ref_string_isalpha.asp
Python String isalpha() Method
The isalpha() method returns True if all the characters are alphabet letters (a-z). Example of characters that are not alphabet letters: (space)!#%&? etc. ... No parameters. Check if all the characters in the text is alphabetic:
Top answer 1 of 8
348
You can use str.isalpha().
For example:
s = 'a123b'
for char in s:
print(char, char.isalpha())
Output:
a True
1 False
2 False
3 False
b True
2 of 8
45
str.isalpha()
Return true if all characters in the string are alphabetic and there is at least one character, false otherwise. Alphabetic characters are those characters defined in the Unicode character database as “Letter”, i.e., those with general category property being one of “Lm”, “Lt”, “Lu”, “Ll”, or “Lo”. Note that this is different from the “Alphabetic” property defined in the Unicode Standard.
In python2.x:
>>> s = u'a1中文'
>>> for char in s: print char, char.isalpha()
...
a True
1 False
中 True
文 True
>>> s = 'a1中文'
>>> for char in s: print char, char.isalpha()
...
a True
1 False
� False
� False
� False
� False
� False
� False
>>>
In python3.x:
>>> s = 'a1中文'
>>> for char in s: print(char, char.isalpha())
...
a True
1 False
中 True
文 True
>>>
This code work:
>>> def is_alpha(word):
... try:
... return word.encode('ascii').isalpha()
... except:
... return False
...
>>> is_alpha('中国')
False
>>> is_alpha(u'中国')
False
>>>
>>> a = 'a'
>>> b = 'a'
>>> ord(a), ord(b)
(65345, 97)
>>> a.isalpha(), b.isalpha()
(True, True)
>>> is_alpha(a), is_alpha(b)
(False, True)
>>>
Videos
05:25
Python Program to Check Character is Alphabet or Not - YouTube
05:13
Python Program to Check Character is Alphabet or not using isalpha() ...
06:03
Write a Python Program to Check Whether a Character is Alphabet ...
01:18
Python Program to Check Character in a String is Alphabet, How ...
01:49
String isalpha() Method | Python Tutorial - YouTube
Codecademy
codecademy.com › docs › python › strings › .isalpha()
Python | Strings | .isalpha() | Codecademy
October 9, 2023 - The .isalpha() string method checks if all of the characters in a string are letters of the alphabet (a-z). The letters can be lowercase or uppercase. If the string only contains letters of the alphabet it returns True, otherwise it returns False.
Scaler
scaler.com › home › topics › isalpha() in python
isalpha() in Python - Scaler Topics
April 7, 2024 - The isalpha() function is a built-in function used for string handling in python, which checks if the single input character is an alphabet or if all the characters in the input string are alphabets.
TutorialsPoint
tutorialspoint.com › how-do-i-check-if-a-string-has-alphabets-or-numbers-in-python
How do I check if a string has alphabets or numbers in Python?
September 2, 2025 - To check if a string contains at least one letter or one digit, you can use a loop to go through each character or apply regular expressions. This is helpful when strings may contain a mix of character types. In this example, we check for the presence of at least one letter or number using a loop and the any() function - text = "abc123!" has_alpha = any(c.isalpha() for c in text) has_digit = any(c.isdigit() for c in text) print("Contains alphabet:", has_alpha) print("Contains digit:", has_digit)
CodeScracker
codescracker.com › python › program › python-program-check-alphabet.htm
Python Program to Check Alphabet or Not
This program does the same job as of previous program, but using a user-defined function named checkAlphabet(). This function receives the character entered by user as its argument and returns 1, if it is an alphabet, otherwise returns 2.
Know Program
knowprogram.com › home › python program to check whether character is alphabet
Python Program to Check Whether Character is Alphabet
April 24, 2021 - # Python program to check whether ... check charater is alphabet or not if((ch>='a' and ch<= 'z') or (ch>='A' and ch<='Z')): print(ch, "is an Alphabet.") else: print(ch, "is not an Alphabet.")...
TutorialsPoint
tutorialspoint.com › article › How-to-check-if-a-character-in-a-string-is-a-letter-in-Python
How to check if a character in a string is a letter in Python?
March 25, 2025 - import string text = "Hello World" index = 1 if text[index] in string.ascii_letters: print(f"The character '{text[index]}' at index {index} is a letter") else: print(f"The character '{text[index]}' at index {index} is not a letter") ... Regular ...
YouTube
youtube.com › watch
Check If String Contains Any Letters from Alphabet in Python (Example) | any() & isalpha() Functions - YouTube
How to test whether a character string contains one or multiple alphabetical letters in the Python programming language. More details: https://statisticsglob...
Published March 17, 2023
Programiz
programiz.com › python-programming › methods › string › isalpha
Python String isalpha()
name = "MonicaGeller" if name.isalpha() == True: print("All characters are alphabets") else: print("All characters are not alphabets.")
GeeksforGeeks
geeksforgeeks.org › python › python-test-if-string-contains-alphabets-and-spaces
Test if String Contains Alphabets and Spaces - Python - GeeksforGeeks
July 12, 2025 - This method iterates through each character in the string, checking whether all characters are either alphabets (isalpha()) or spaces (isspace()) and the all() function ensures the condition holds true for the entire string. ... s = "geeksforgeeks is best for geeks" # Check if all characters are alphabets or spaces res = s != '' and all(c.isalpha() or c.isspace() for c in s) print("Does the string contain only alphabets and spaces:", res)
Stack Overflow
stackoverflow.com › questions › 73310311 › check-whether-a-character-is-an-alphabet-digit-or-special-character-python
if statement - Check whether a character is an alphabet, digit or special character- PYTHON - Stack Overflow
You could also utilize Python's String methods isalpha() and isnumeric(). def get_char(): """ Prompt user for character input, or exit if user enters more than a single character.