Merge Two Dictionaries that Share Same Key:Value

Viewed 185

I know this can be done with lists, but I'm just trying to figure out how to do this with dictionaries.

Basically, it'll go like this:

dict1 = {'a': 10, 'b': 12, 'c': 9}
dict2 = {'a': 10, 'b': 3, 'c': 9}

def intersect(dict1, dict2):
    combinDict = dict()


....
print(combinDict)
{'a': 10, 'c':9}

So I only want the keys with the same value added into a new dictionary.

Any help?

2 Answers
Related