Skip to main content

What are sets?

Sets are collections that only store unique values. They automatically remove duplicates. Think of sets like:
  • A bag of unique marbles
  • Guest list (each person once)
  • Unique tags or categories

Creating sets

You can create sets two ways: with set() or with curly braces {} (but only when it has values).
Use set() for empty sets, not {}. Empty curly braces create a dictionary!

Basic operations

Common uses

Remove duplicates

Fast membership testing

Common mistakes

What’s next?

Congratulations! You’ve completed Python Basics. Ready to start building programs?

Building Programs

Learn about functions