# Sets — Python

Source: https://www.geekswithgeeks.com/en/python/py-sets

> Unordered collections of unique items, built for membership and set math.

## Unique & fast lookups

A **set** automatically drops duplicates and checks membership in near-constant time.

```python
tags = {"python", "web", "python"}
print(tags)          # {'python', 'web'}
print("web" in tags) # True
```

## Set operations

Sets support math operations: union, intersection, difference — handy for comparing groups.

```python
a = {1, 2, 3}
b = {2, 3, 4}
print(a | b)   # union {1,2,3,4}
print(a & b)   # intersection {2,3}
print(a - b)   # difference {1}
```
