๐ Day 24/150 – Check Vowel or Consonant in Python
One of the simplest and most important beginner problems in Python is checking whether a character is a vowel or a consonant. It helps you understand conditions, strings, and user input.
๐ What is a Vowel?
Vowels in English are:
a, e, i, o, u
(Also consider uppercase: A, E, I, O, U)
Everything else (alphabets) is a consonant.
๐น Method 1 – Using if-else
๐ง Explanation:
- char.lower() converts input to lowercase.
- 'aeiou' contains all vowels.
- in checks if the character exists in that string.
๐ Best for: Clean and readable logic.
๐น Method 2 – Taking User Input
๐ง Explanation:
- Takes input from user.
- Works for both uppercase and lowercase.
๐ Best for: Interactive programs.
๐น Method 3 – Using Function
๐ง Explanation:
- Function makes code reusable.
- Returns result instead of printing directly.
๐ Best for: Structured programs.
๐น Method 4 – Using Lambda Function
๐ง Explanation:
- Short one-line function.
- Uses inline if-else.
๐ Best for: Quick checks.
⚡ Key Takeaways
- Use in keyword for easy checking
- Convert to lowercase using .lower()
- Always validate user input
- Vowels = aeiou
๐ก Pro Tip
Try extending this:
- Count vowels in a string
- Check vowels in a sentence
- Build a mini text analyzer

.png)
