Below python code will identify character whether it is alphabet or number using comparison and built in function like isalpha, isdigit
# Program to check if character is alphabet or not.
#Take user input and store it in variable ch
ch = input("Enter a character to check if character is alphabet or not: ")
#comparing characters with a to Z or A to Z
if((ch>='a' and ch<= 'z') or (ch>='A' and ch<='Z')):
print(ch, "is an Alphabet")
else:
print(ch, "is not an Alphabet")
# using IsAlpha function
if (ch.isalpha()):
print(ch, "is an Alphabet identified using Is ALPHA function")
else:
print(ch, "is not an Alphabet")
# using IS digit function
if(ch.isdigit()):
print(ch, "is an number identified using IS Digit function")
Enter a character to check if character is alphabet or not:
5
5 is not an Alphabet
5 is not an Alphabet
5 is an number identified using IS Digit function
Enter a character to check if character is alphabet or not:
s
s is an Alphabet
s is an Alphabet identified using Is ALPHA function