I want to compare the values of two dict if the frequency of elements are the same or not, elements can be different but their frequency should be the same.
dict1 = {'a':1, 'b':2, 'c':3}
dict2 = {'x':1, 'y':2, 'z':3}
# when I do a comparison of values, it doesn't work
print(dict1.values())
print(dict2.values())
if dict1.values() == dict2.values():
print("Equal")
else:
print("Not Equal")
Output:
dict_values([1, 2, 3])
dict_values([1, 2, 3])
Not Equal
So even though the output of dict.values() is same but they are not equal. Is this comparison not allowed and is there any other way to do the same?