Check a String is Alphabet in Python

  • Post category:String

In this article, you will see how to check a string is alphabet in Python. An alphabet string is a string that contains only letters. The string isalpha() method returns True if all characters in the string are alphabets, otherwise False.

Step 1: Create a string

str = "CodeAllow"
print("str = ", str)
print("str type = ", type(str))

Step 2: Check if a string is an alphabet

if all(c.isalpha() for c in str):
    print("Alphabet")
else:
    print("Not Alphabet")

Output:

str =  CodeAllow
str type =  <class 'str'>
Alphabet

Free resources to learn advanced skills: AiHints and CodeAllow