BeginnerCoder

Lesson 5 — Set comprehensions & dedupe

Sets in one line

A set comprehension looks like a list comprehension with curly braces: {x for x in ...}. Sets drop duplicates automatically, so this is the quickest way to find unique values.

Want it another way?
Task

Build a set of the unique word lengths in the list and print it sorted.

Run your code — when the output matches the task, you will see a green check. Then mark the lesson complete.

← Back
Next →
Test your knowledge

A quick 3-question quiz on this lesson — instant feedback.

Enjoying this lesson? Share it.