To get the elements that are only in one set and not in the other set, you can use the set symmetric difference operator ^
in Python.
Here's an example:
main.py200 chars9 lines
Output:
main.py66 chars3 lines
In this example, set1 ^ set2
gives the elements that are only in set1
, and set2 ^ set1
gives the elements that are only in set2
.
gistlibby LogSnag