gpt-4.1-mini-2025-04-14· OpenAI
WildChat-4.8M (AI2)
Task: Take one character as input from
- User
Task: Take one character as input from user:
If it is a vowel (a, e, i, o, u) ➔ "Vowel"
If it is a consonant ➔ "Consonant"
If it is a digit (0-9) ➔ "Digit"
If it is a special character (@, #, etc.) ➔ "Special Character"
(Hint: You can use .isalpha() and .isdigit())
- Assistant
Here's a Python program that takes one character as input from the user and classifies it as "Vowel", "Consonant", "Digit", or "Special Character":
python# Take one character input from user char = input("Enter one character: ") # Check if the input is exactly one character long if len(char) != 1: print("Please enter exactly one character.") else: # Check if the character is a digit if char.isdigit(): print("Digit") # Check if the character is an alphabet elif char.isalpha(): # Check if it's a vowel if char.lower() in ['a', 'e', 'i', 'o', 'u']: print("Vowel") else: print("Consonant") else: # If not digit or alphabet, it's a special character print("Special Character")