Python Program to Check Alphabet
In this post, we will write a Python program to check whether the entered character is an Alphabet or not.
Python code
In this program, user is asked to enter a character and the input character is stored in a variable. The program checks whether the entered character lies in the range of lowercase or uppercase alphabets, if it does then the program displays the message that the character is an Alphabet else it displays that the character is not an Alphabet.
# taking user input
ch = input("Enter a character: ")
if((ch>='a' and ch<= 'z') or (ch>='A' and ch<='Z')):
print(ch, "is an Alphabet")
else:
print(ch, "is not an Alphabet")
Output
Enter a character: a
a is an Alphabet
Leave Comment