I have 2 dictionaries with the same keys:
d={123:'bla', 456: blabla}
e={123:'bla', 456:''}
Dictionary e has some empty values and if this is the case and the IDs are the same I’d like to replace the empty value with the value from d.
I am looking for something like this:
if d.keys()==e.keys():
e.values==d.values()
print e
However, I couldn’t find anything in the Python documentation that compares single keys and updates the values.
Can someone help or point me at something?
Thanks 🙂
You can do a straight update if you don’t mind overwriting differing values with
or if you want to make sure you only overwrite the ones containing empty values then you will need to iterate over your dictionary to find them, and update selectively