My code prints the item, price, and stock - why isn’t it accepted?



My code prints the item, price, and stock - why isn’t it accepted?


Codecademy checks for exactly the answer that it’s looking for in the instructions. This includes spelling, capitalization, spacing, and punctuation. If any of those are different, it’ll count it wrong.
The most common issue is printing prices: rather than price:, or capitalizing either word printed out.
Also, be sure to convert the value stored in the dictionaries to a string using the str() function so you can print it out!

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

It prints identical to the solution command lines…?
I just did it slightly differently


the exercise validates the presence of the 3 print keywords, which is why this isn’t working


Oh, I get it. Thanks.


I don’t understand this – in the case of prices you use price but where there is no s as in stock you simply use stock…very confusing


Thanks for this! I had written for

key in prices:
  price: %s
  stock: %s""" % (key, prices[key], stock[key]))

and I couldn’t figure out why it was being rejected. You clarified it!


Thanks to everyone who replied, i finally figured it out. thanks 5beatspersecond for the \n i realized what it does after playing around with it

print "price: %s" % prices[number]

Your iterator variable is n, so that is the key you should be polling.


Why is it printing out of order? Like shouldn’t banana be printed first, then apple, orange, etc.? It prints orange first, why is that?


Plain objects are not ordered like indexed objects such as arrays. There is no record of the order of insertion so no predicting the order of output.