Python

DEXUAN LI
DEXUAN LI
6,222 Points

what is the meaning for these -, |, ^ between set actually?

set1 - set2 set1 & set2 set1 | set2 set1 ^ set2

1 Answer

Steven Parker
Steven Parker
94,464 Points

Those are the set combining operators:

  • | = Union — all items from both sets
  • & = Intersect — items in common to both sets
  • - = Difference — items from first set that are not in the second set
  • ^ = Symmetric Difference — items from both sets not in the other (opposite of intersect)
DEXUAN LI
DEXUAN LI
6,222 Points

very clear explanation. thanks!

Steven Parker
Steven Parker
94,464 Points

DEXUAN LI — Glad to help. You can mark the quesiion solved by choosing a "best answer".
And happy coding!