Skip to content

Instantly share code, notes, and snippets.

# compare two dictionaries and return which items have different values
def dict_diff(dict1, dict2):
diff = {}
keys_d1 = dict1.keys()
keys_d2 = dict2.keys()
for key_d1 in keys_d1:
if key_d1 in keys_d2:
if dict1[key_d1] != dict2[key_d1]:
diff[key_d1] = (dict1[key_d1], dict2[key_d1])
else: