Use the symmetric difference operator for set
s (aka the XOR operator):
>>> set([1,2,3]) ^ set([3,4,5])
set([1, 2, 4, 5])
More Related Contents:
- Removing duplicates in lists
- Permutations between two lists of unequal length
- How to efficiently compare two unordered lists (not sets) in Python?
- Python Sets vs Lists
- Pythonic way to check if a list is sorted or not
- Python -Intersection of multiple lists?
- Detecting consecutive integers in a list [duplicate]
- In Python, when to use a Dictionary, List or Set?
- What makes sets faster than lists?
- How to efficiently compare two unordered lists (not sets)?
- In Python, what is the fastest algorithm for removing duplicates from a list so that all elements are unique *while preserving order*? [duplicate]
- Add list to set
- How to construct a set out of list items in python?
- How to compare a list of lists/sets in python?
- How to make a set of lists
- Complexity of list.index(x) in Python
- What is the difference between sets and lists in Python?
- Get unique values in List of Lists
- Which is faster and why? Set or List?
- Python: find closest string (from a list) to another string
- What is time complexity of a list to set conversion?
- Fastest way to search a list in python
- Sliding window maximum in O(n) time
- Get difference between two lists with Unique Entries
- How to split an iterable into two lists with alternating elements
- How can I match up permutations of a long list with a shorter list (according to the length of the shorter list)? [duplicate]
- set of list of lists in python
- A set union find algorithm
- Python: powerset of a given set with generators [duplicate]
- Python – Removing overlapping lists