Set Operations: Union, Intersection, Difference in Python


Perform mathematical set operations.

Source Code

a = {1, 2, 3}
b = {3, 4, 5}
print(a | b)  # Union
print(a & b)  # Intersection
print(a - b)  # Difference
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments