If you use a dictionary in a for statement, it traverses
the keys of the dictionary. For example, print_hist
prints each key and the corresponding value:
Here’s what the output looks like:
Since Python 3.7, the keys are in the order they were inserted. But we should not rely on this order. To traverse the keys in sorted order, you can use the built-in function sorted: