
stackoverflow.com
https://stackoverflow.com/questions/4527942/compar…
python - Comparing two dictionaries and checking how many (key, value ...
I have two dictionaries, but for simplification, I will take these two: >>> x = dict(a=1, b=2) >>> y = dict(a=2, b=2) Now, I want to compare whether each key, value pair in x has the same corresponding value in y. So I wrote this: >>> for x_values, y_values in zip(x.iteritems(), y.iteritems()): if x_values == y_values: print 'Ok', x_values, y_values else: print 'Not', x_values, y_values And it ...