intersection of dictionary python values code example
Example: intersection python dict
Python 3.6.9 (default, Oct 8 2020, 12:12:24)
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> a = {'a': 123, 'c': 5}
>>> b = {'a': 2, 'b': 4}
>>> a.keys() & b.keys() # intersection
{'a'}
>>> a.keys() ^ b.keys() # difference
{'b', 'c'}
>>> a.keys() - b.keys() # subtraction
{'c'}