[python] Is there a better way to compare dictionary values