Difference of Sets
The
difference operation on two sets produces a new set containing only the
elements from the first set and none from the second set. In the below example
the element “Wed” is present in both the sets so it will not be found in the
result set.
DaysA =
set(["Mon","Tue","Wed"])
DaysB =
set(["Wed","Thu","Fri","Sat","Sun"])
AllDays = DaysA – DaysB
print(AllDays)
|
When
the above code is executed, it produces the following result. Please note the
result has only one “wed”.
set(['Mon', 'Tue']) |
<<< Intersection of Sets Go to Index Compare Sets >>>