I have two dictionaries with the same keys and I would like to do division on the values to update or create a new dictionary, keeping the keys intact, with the quotient as
d1 = { 'a':12 , 'b':10 , 'c':2 } d2 = { 'a':0 , 'c':2 , 'b':5} d3={x:float(d2[x])/d1[x] for x in d1} print d3
output:
{'a': 0.0, 'c': 1.0, 'b': 0.5}