New Entries - what are the sequences?


no error occurred

however, i'd like to know what are the sequences of adding these items??
it does not seem like following alpha or time?

menu = {} # Empty dictionary
menu['Chicken Alfredo'] = 14.50 # Adding new key-value pair
print menu['Chicken Alfredo']

# Your code here: Add some dish-price pairs to menu!
menu['Stinky Tofu'] = 5.5
menu['French Fried'] = 9.0
menu['Pasta'] = 12

print "There are " + str(len(menu)) + " items on the menu."
print menu

it turns out as below

There are 4 items on the menu.
{'Pasta': 12, 'Chicken Alfredo': 14.5, 'French Fried': 9.0, 'Stinky Tofu': 5.5}


dictionaries are unordered, you access by key (not by index), so why would you need order?

having said this, in python3.6 dictionaries are ordered


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