Unique Vowels with a Set Comprehension
Intermediate · Write the code · from Python Comprehensions: List, Dict, Set, and Generator in One Guide
From the lesson: Python Comprehensions: List, Dict, Set, and Generator in One Guide
Imagine you have a list of 100 numbers and you want a new list containing only the even ones, each doubled. With a regular loop, that takes four lines. With a Python comprehension, it takes one.
Read the lessonUse a set comprehension to find all unique vowels in the given word. Store the result in a variable called vowels_found, then print it sorted as a list.
Expected output:
['a', 'e', 'i', 'o']word = 'conversation'
# Find unique vowels using a set comprehension
# Print them sorted
More Comprehensions exercises
- Double Every NumberBeginner
- Filter Even NumbersBeginner
- Predict the Output: if vs if-elseIntermediate
- Create a Dict ComprehensionIntermediate
- Fix the Bug: Wrong Comprehension SyntaxIntermediate
- Refactor a Loop into a ComprehensionIntermediate
- Flatten a MatrixAdvanced
All Python exercises · 50 practice problems · Data Structures quiz