Printing dictionaries - key and value?


Why in subsection 11 when you call 'print menu' does it print the keys and the values but in subsection 12 it only prints the keys when you call 'print zoo_animals'? Does it only print the value if it's not a string?


All values in Python are objects.
Which means that somewhere there's a class that define what the objects do.

Classes define how to iterate through their objects.

Iterating through a dictionary will produce the keys of that dictionary.

If you want the values as well, you can instead iterate through dict.items() or look them up using the keys

The types of the keys or values do not affect this behaviour.