Questions
Program to check whether given character is vowel or not.
Last Updated : 16 Jul 2025
Jan 22, Jul 24
Solution:
# Prompt the user to enter a character
c = input("Enter any char: ")
# Define a list of vowels (both lowercase and uppercase)
vowels = ['a', 'A', 'e', 'E', 'i', 'I', 'o', 'O', 'u', 'U']
# Check if the entered character is in the list of vowels
if c in vowels:
# If true, print "Vowel"
print("Vowel")
else:
# If false, print "Not a vowel"
print("Not a vowel")
OUTPUT:
Enter any char k
not a vowel
Explaination:
This code checks if a given character is a vowel:
- Input: Prompts the user to enter a character.
- Vowel List: Defines a list of vowels (both lowercase and uppercase).
- Condition: Checks if the character is in the vowel list.
- Output: Prints "Vowel" if true, otherwise prints "Not a vowel".
Meanwhile you can watch this video
Watch Video