Python Practice › If-Else Programs › Program 32
Check a vowel
Write a Python program to check whether a letter is a vowel.
Input
"A", "k"
Output
A True k False
Approach
- Lower-case the letter and check membership in “aeiou”.
Solution
for ch in ["A", "k"]: if ch.lower() in "aeiou": print(ch, True) else: print(ch, False)Output
A True k False
Line by line
Line 2
in on a string checks whether the character appears in it.
Learn the concept
New to this topic? Read the lesson, then come back.