Python Program to check if user input value is english alphabet or not


February 21, 2022, Learn eTutorial
1017

In this simple python program, we need to check the given data is an English alphabet or not. It is a beginner-level python program.

For a better understanding of this example, we always recommend you to learn the basic topics of Python programming listed below:

How to check input is an alphabet or not in python?

This python program is to check the user input is an alphabet or any other. The user has to input either a Number or Special character or Alphabet uppercase or lowercase in normal case. So the basic logic is to check the condition as if the user input is between lower case 'a' and 'z' or between the upper case 'A' and 'Z'. If so, we have to print it as an alphabet, else it is not an alphabet. We can apply this logic because every alphabet has an ASCII value, so we can use the less than and greater if condition in python easily.

ALGORITHM

STEP 1: Accept the user's input value using the input function in python language and store the value in a variable.

STEP 2: Use the if condition to check the input value is between 'a' and 'z' or between 'A' and 'Z'. We apply the ASCII value of the alphabet to apply the if condition.

STEP 3: Print the result as the entered input value is an Alphabet.

STEP 4: Use the else statement in the python programming and print the input value is not an alphabet.

Python Source Code

                                          ch = input("Enter any input value: ")

if((ch>='a' and ch<= 'z') or (ch>='A' and ch<='Z')):    # checking the condition using the if statement as the entered value is between the alphabet ASCII value. 

    print(ch, "Entered value is an Alphabet")

else:

    print(ch, "Entered value is not an Alphabet")
                                      

OUTPUT

Enter any input value: J

J Entered value is an Alphabet