Python Tip #164 (of 365):
Thinking in terms of a Venn diagram? You need a set.
Need to find all items in one collection but not another? Intersect two collections? Check what's unique to each?
Python's sets support set arithmetic using operators:
>>> a = {1, 2, 3, 4, 7}
>>> b = {1, 3, 5, 7, 9}
>>> a | b
{1, 2, 3, 4, 5, 7, 9}
>>> a & b
{1, 3, 7}
>>> a - b
{2, 4}
>>> a ^ b
{2, 4, 5, 9}
π§΅ (1/2)



