This Python program reads a single character from the user and determines its category:
- Vowel (a, e, i, o, u)
- Consonant (any alphabetic character that is not a vowel)
- Digit (0–9)
- Other characters (symbols, punctuation, etc.)
char = input("Enter a character: ").lower()
if char.isalpha():
if char in "aeiou":
print("The character is a vowel.")
else:
print("The character is a consonant.")
elif char.isdigit():
print("The character is a digit.")
else:
print("The character is an other symbol.")
Enter a character: A
The character is a vowel.
Enter a character: 7
The character is a digit.
Enter a character: %
The character is an other symbol.
- The input is converted to lowercase to simplify vowel checking
- If the character is alphabetic, it is checked against the vowel list
- If it’s a digit, it’s classified accordingly
- All other characters fall into the “other” category