Learn about Python Program to Check Whether Character is Alphabet in the below code example. Also, refer to the comments in the code snippet to get a detailed view about what’s actually happening.
Contents
Python Program to Check Whether Character is Alphabet
The if-else statement is used in this Python program to determine whether a character is alphabetic or not. While declaring the variables, we will take on the role of a character. Then, using the if-else statement, determine whether the character is an alphabet.
Program:
# Python program to check whether a character is alphabet or not
# input character
ch = input("Enter any character: ")
# check charater is alphabet or not
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 any character: t
t is an Alphabet.
Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.
Similar Code : Check Whether a character is Vowel or Consonant using ASCII value Python