← Python Foundations
12 / 27
Lesson 12 — Sets
Unique values
A set stores each value only once and has no fixed order. Create one with curly braces or by passing a list to set(), and duplicates disappear automatically. Checking x in my_set is also very fast, even for huge sets.
tags = set(["python", "web", "python"])
print(len(tags)) # 2
Why it matters: removing duplicates — repeated emails, visitors, tags — is one of the most common data-cleaning jobs.
Want it another way?
Task
Turn the list into a set and print how many unique values there are.
Run your code — when the output matches the task, you will see a green check. Then mark the lesson complete.
Test your knowledge
A quick 3-question quiz on this lesson — instant feedback.