I'am trying to compare 2 lists of dictionary to replace equal values. for example:
d1 = [{'a': 'hello', 'b':'world','c':'this','d':'is'},{'a':'ddd' ,'b': 'www','c':'hah','d':'tt'},.....]
d2 = [{'Q': 'hello', 'H':'target_word','K':'that','N':'was'},{'Q':'world' ,'H': 'target_word','K':'hah','N':'txt'},.....]
Can someone tell me how can I compare the keys ('a','b') in d1 with 'Q' in d2 if they have the same value then it must replace 'a's and 'b's value in d1 to 'H's value in d2 which is 'target_word'
this one of my attempts:
for i in d1:
for j in d2:
for k in i.keys():
for k1 in j.keys():
if j[k1] == i[k]:
i[k] = j ['H']
list.append(i[k])