intersection python dict

Solutions on MaxInterview for intersection python dict by the best coders in the world

showing results for - "intersection python dict"
David
01 Mar 2018
1Python 3.6.9 (default, Oct  8 2020, 12:12:24) 
2[GCC 8.4.0] on linux
3Type "help", "copyright", "credits" or "license" for more information.
4>>> a = {'a': 123, 'c': 5}
5>>> b = {'a': 2, 'b': 4}
6>>> a.keys() & b.keys()  # intersection
7{'a'}
8>>> a.keys() ^ b.keys()  # difference
9{'b', 'c'}
10>>> a.keys() - b.keys()  # subtraction
11{'c'}