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
06:03
Write a Python Program to Check Whether a Character is Alphabet ...
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() ...
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 - In Python, you can check whether a string contains letters, numbers, or both using built-in string methods such as isalpha(), isdigit(), and isalnum(). You can also use loops or regular expressions for more customized checks.
PREP INSTA
prepinsta.com › home › python program › python program to check whether a character is an alphabet or not
Character is alphabet or not in python | Programming | PrepInsta
October 13, 2022 - char = input(‘enter a character’) if char.isalpha(): print(‘The char contains only alphabets’) else: print(‘The char contains different values along with alphabets’) ... a=input(“”) s=”A”,”E”,”I”,’O’,’U’,’a’,’e’,’i’,’o’,’u’ q=0 for i in s: if(a==i): q=q+1 if(q>=1): print(“vowel”) else: print(“not a vowel”) ... # Program to check the char is alphabet r not c=input(“Enter a char: “) print(c,”Is Alphabet”) if c.isalpha() else print(c,”Is not alphabet”)
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 a character is alphabet or not # take input ch = input("Enter any character: ") # check charater is alphabet or not if(ch.isalpha()): 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)
Devcuriosity
devcuriosity.com › manual › details › python-isalpha-function
Python - isalpha() - Check if a string contains only letters
string.isalpha() is a method that we can call on string, byte, and bytearray objects. It checks if a given object contains only letters or rather - alphabetic characters.