Operations on Sets
The set and frozenset type support a number of common set operations:
Operation | Description |
---|---|
s | t | Union of s and t |
s & t | Intersection of s and t |
s – t | Set difference |
s ^ t | Symmetric difference |
len(s) | Number of items in the set |
max(s) | Maximum value |
min(s) | Minimum value |
Get Python: Essential Reference, Third Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.