You can find the symmetric difference of two maps in Python by converting the maps to sets and finding the symmetric difference of the sets.
main.py171 chars8 lines
In this example, the symmetric difference between map1
and map2
is a set that contains the key-value pairs ("a", 1)
, ("c", 3)
, and ("d", 5)
.
Note that when converting a map to a set, you need to use the items()
method to get a set of key-value pairs.
gistlibby LogSnag