A quiz on Python dictionaries offered the following question:
What is the output of the following code?
oscars = {"Best Picture": "Moonlight", "Best Actor": "Casey Affleck", "Best Actress": "Emma Stone", "Animated Feature": "Zootopia"}
for element in oscars:
print(element)
This piece of code returns printed keys. I’m not sure why the for loop takes into account only keys as an “element” here. This code does not use the .keys method. So why is not a “key-value” pair regarded as an element instead?