I have two dictionaries like below which have common keys:
dictionary1 = {1: 'a', 2: 'b' , 3: 'c'}
dictionary2 = {1: 'no', 2: 'yes' ,3:'yes'}
I want to create a new dictionary with the key and values of dictionary1 only if the corresponding values of the dictionary2 key has "yes".
Expected output:
{2: 'b', 3: 'c'}
What I have tried:
dictionary1 = {1: 'a', 2: 'b' , 3: 'c'}
dictionary2 = {1: 'no', 2: 'yes' ,3:'yes'}
common_pairs = dict()
for key,value in dictionary2.items():
for key,v in dictionary1.items():
if(value == "yes"):
common_pairs[key] = v