Set Methods
| Method | Description |
|---|---|
add(x) | Add an element |
update(iterable) | Add many elements |
remove(x) | Remove x (error if missing) |
discard(x) | Remove x if present |
pop() | Remove and return an arbitrary element |
clear() | Remove all |
union(other) | Return union |
intersection(other) | Return intersection |
difference(other) | Return difference |
issubset(other) / issuperset(other) | Subset tests |
Example
a = {1, 2}
a.add(3)
print(a.intersection({2, 3, 4}))