Archive
Posts Tagged ‘comparing dictionaries’
You can compare two dictionaries
November 8, 2013
Leave a comment
In Python you can compare two dictionaries. Proof:
>>> a
{'a': 1, 'c': 3}
>>> b
{'a': 1, 'c': 3}
>>> a == b
True
>>> b['c'] = 4
>>> a
{'a': 1, 'c': 3}
>>> b
{'a': 1, 'c': 4}
>>> a == b
False
(Note that comparison works between two strings and between two lists too.)
Thanks to Eszter S. for the tip.
Categories: python
comparing dictionaries, dict, dictionary
