Dictionary order


#1

Why does the output get ordered from most to least in stock? Why not just the order we entered for the dictionary, or why is it only ordered by the stock dictionary?


FAQ: Learn Python: A Day at the Supermarket - Keeping Track of the Produce
FAQ: Learn Python: A Day at the Supermarket - Keeping Track of the Produce
#2

Dictionaries in Python 2 do not remember the order of insertion. It is not a concern though. When iterating over a dictionary the order does not matter since all entries are reached, regardless the order.


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.