Editor

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 lesson

Use 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

All Python exercises · 50 practice problems · Data Structures quiz