[Solved] Why do keys() and items() methods return different Boolean values for same key? (Python 3.6) [closed]

items() contains tuples, key-value pairs: >>> spam.items() dict_items([(‘name’, ‘Zophie’), (‘age’, 7)]) Your key is not such a tuple. It may be contained in one of the tuples, but in does not test for containment recursively. Either test for the correct key-value tuple: >>> (‘name’, ‘Zophie’) in spam.items() True or if you can’t get access to … Read more