how to check key and values in python