codescracker


python

Python Program to Check Alphabet or Not



« Previous Program Next Program »


Check Alphabet or Not in Python

To check whether the given character is an alphabet or not an alphabet in python, you have to ask from user to enter a character to check for alphabet as shown in the program given here.

Python Programming Code to Check Alphabet or Not

Following python program ask from user to enter any character to check for alphabet:

# Python Program - Check Alphabet or Not

print("Enter '0' for exit.");
ch = input("Enter any character: ");
if ch == '0':
    exit();
else:
    if((ch>='a' and ch<='z') or (ch>='A' and ch<='Z')):
    	print(ch, "is an alphabet.");
    else:
    	print(ch, "is not an alphabet.");

Here is the sample run of the above Python program shows how to check whether the given character is an alphabet or not:

Let's first see the initial output asking from the user to enter any character to check it out:

check alphabet or not python

Now type anything say 20 as input to see what the above program will print. As 20 is not an alphabet, therefore here is the output you will watch after performing the same:

check alphabet python

And type a to check it out again. As this time a is an alphabet, therefore, a is an alphabet will be printed as output as shown here in the following screenshot:

python check alphabet or not

Below is the same program written and run on python shell:

python check alphabet

Program Video with Compile and Run

Same Program in Other Languages

You may also like to learn or practice the same program in other popular programming languages:


« Previous Program Next Program »








Tools
Calculator

Quick Links
Signup - Login - Give Online Test