You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Dictionaries compare equal if and only if they have the same (key, value) pairs (regardless of ordering). Order comparisons (‘<’, ‘<=’, ‘>=’, ‘>’) raise TypeError
So it should behave differently than in lists where order matters.
I think the case may be
Since there is no index in dictionary introduces then whats the point of comparing the elements in index way, the order preservence was just to make retrival easy
We could compare the enumerate of both dicts to solve the issue. Since it will return a list of tuples and would check as a list. Would be happy to work on this. Not sure who to tag to be assigned to this issue.
I'm using Python 3.8.5.
According to official Python docs (https://docs.python.org/3.8/library/stdtypes.html#mapping-types-dict):
So technically, in
test_dictionary_is_unordered()
, dict1 == dict2 should always return False. It doesn't for some reason I can't seem to work out.Playing around with the Python console:
I guess maybe this means that
==
means something slightly different fordict
than I expected?The text was updated successfully, but these errors were encountered: