I am trying to compare two dictionaries with the desired outcome being a KeyError that identifies the Key that is missing.
this is what i currently have:
d1 = {'lion': 10.0}
d2 = {'lion': 10, 'tiger': 3}
def calc_test(d1, d2):
if set(d2) <= set(d1) == True:
pass
else:
raise KeyError(set(d2))
calc_test(d1,d2)
if you run this though it gives the output of the entire dictionary:
KeyError: {'lion', 'tiger'}
what i'm seeking is an output that only shows the missing key:
KeyError: {'tiger'}