Part of the series

Several example codes

~1 min read • Updated Oct 7, 2025

Program Overview

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.)


Python Code:


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.")

Sample Output:


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.

Step-by-Step Explanation:

- 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


Written & researched by Dr. Shahin Siami