Had trouble understanding why an error popped up at the editor page saying: " Check what your code prints for orange. It doesn’t look quite right"
This was what i did on the editor:

for x in prices:
print x
print “prices: %s” % prices[x]
print “stock: %s” % stock[x]

Thereafter, i got the code answer from codeacademy:

for food in prices:
print food
print “price: %s” % prices[food]
print “stock: %s” % stock[food]

Realized that the singular form of ‘price’ in codeacademy’s answer was the differentiating factor, even though ‘prices’ was the correct name of the list in the first place. Is there something i’m missing?

Help is great appreciated…thanks!!


the variable name doesn’t matter, but i would pick a logic name which describes what the variable contains. its good practice

this does matter, codecademy told you the output need to be an exact match. A single product has a price, not multiple prices

not sure what help you still need


hey can someone tell me when you print a dictionary, e.g.

dict = {apple: 33, orange: 31, pear: 30}
print dict

What will be the order of key?


not relevant, we use keys for a reason. You can sort the dictionary if you want to, you can use an ordered dictionary (python has this, but you would need to think about the advantage and disadvantages of this approach), i wouldn’t bother with the underlying hash table of the dictionary, its not what you should focus on


I see, thanks for the reply. I was just curious because I notice it doesn’t follow the index order like lists do when it is print.


Given there are accessed by key, they don’t need to be ordered


Got it. Thanks for the reply!