Program to check character is alphabet or not in Python

Program to check character is alphabet or not in Python

In this program, you will learn to check if the given character is alphabet or not. This is done using the if else statement in Python Programming.

In this program, the user is asked to enter a character and the input character is stored in a variable. The program checks whether the entered character is alphabet or not and the program displays the message "Alphabet", otherwise it displays "not Alphabet".


Python code:

ch = input('enter any alphabet:')
if(ch>='a' and ch<='z')or(ch>='A' and ch <= 'Z'):
print('enter character is alphabet')
else:
print('enter character is not an alphabet')

Output:

Case 1: enter any alphabet:A

enter character is alphabet

Case 2: enter any alphabet:h

enter character is alphabet

Case 3: enter any alphabet:2

enter character is not an alphabet