Dremendo Tag Line

Check character is alphabet in Python

if else - Question 11

In this question, we will see how to check if a character is an alphabet or not in Python programming using the if else statement. To know more about if else statement click on the if else statement lesson.

Q11) Write a program in Python to input a character and check if it is an alphabet or not. Make use of logical operators (and, or) to solve this question.

Program

x=input('Enter a character ')

if (x>='A' and x<='Z') or (x>='a' and x<='z'):
    print('Its an alphabet')
else:
    print('Its not an alphabet')

Output

Enter a character G
Its an alphabet
video-poster