Sets & Uniqueness1 / 4
CRASH COURSE
Sets & Uniqueness
A set stores unique hashable values. Repeated values collapse into one item. Sets do not promise a meaningful display order.
- Use in for membership and & for intersection: values present in both sets. The | operator makes a union.
- Use sorted when you need a predictable list for display. An empty set is set(); {} creates an empty dictionary.
tags = {"python", "web", "python"}
print(len(tags))
print("web" in tags)