I merge 2 dictionaries, say d1
and d2
by:
d1.update(d2)
i.e I have:
d1 = {1:'a', 2:'b', 3:'c'}
d2 = {1:'a', 2:'g', 4:'x'}
then after d1.update(d2)
I have:
{1: 'a', 2: 'g', 3: 'c', 4: 'x'}
So the original 2:'b'
vanished so I'd like to have the translation 'b':'g' somehow, meaning the output will be the following dictionary:
{'b':'g'}
Is there any simple code to keep the overridden values?