Lesson 6: Sets — unique values
A set is a collection of unique values — no duplicates and no guaranteed order. It's great for removing duplicates from a list and for fast membership checks with in. Note: empty curly braces {} make an empty dict — an empty set is created with set().
A set is like a bag of marbles where each marble appears only once. Order doesn't matter — what matters is who's inside.
- set
- A collection of unique values with no guaranteed order, written with curly braces.
- deduplication
- Keeping a single copy of each value; turning a list into a set does this.
- membership
- Checking whether a value is in a collection with in; on a set this is very fast.