How can I print the items in a dictionary?


#1

Question

How can I print the items in a dictionary?

Answer

To print all of the items in a dictionary at once, we can use the dictionary’s .items() method. To do this, we simply write print dictionary_name.items().
This will display all of the dictionary’s keys and values as tuples in no particular order.


FAQ: Learn Python - Advanced Topics in Python - Iterating Over Dictionaries