I am looking for a single set operation to accomplish both the cases below. Is there a way to do this python?
Case 1:
a = set([1,2])
and b = set([1,2,3])
I want a result [1,2]
, which is a straightforward intersection. Now set(a)
could be empty and performing intersection on empty set with any other set would lead to empty set.
Case 2:
a = set([])
and b = set([1,2,3]) => set([1,2,3])
i.e. set b
How can I achieve case 1 and case 2 with one set operation.