Sets
Unordered collections of unique items with fast membership tests and set algebra.
Beginner
pins_used = {2, 3, 13}
13 in pins_used # True — very fast check
pins_used | {4, 5} # union
pins_used & {3, 4} # intersection → {3}
Use a set to remove duplicates: unique = set(items).
Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.
Discussion (0)
Sign in or join free to ask questions and discuss this topic.