8... Keeping track of produce "Check what your code prints for orange."


I've read all the other topics on this and what prints is exactly what is expected to print.. I'm so clueless as to what is wrong here...


I know that i can change the last two print lines to
print "price: " + str(prices[item])
print "stock: " + str(stock[item])

However in the instructions it tells me I can use the syntax from the example:

once = {'a': 1, 'b': 2}
twice = {'a': 2, 'b': 4}
for key in once:
print "Once: %s" % once[key]
print "Twice: %s" % twice[key]

I'm trying to understand why it fails when I use that syntax.


For the string on line 5, you should have price singular instead of prices with an s.

The prices[key] bit should still have an s on prices, though.


well dang it.... that is just stupid


Can you re-post your updated code? Only the first part (the string) should have a singular price.


prices = {"banana": 4, "apple": 2, "orange": 1.5, "pear": 3}
stock = {"banana": 6, "apple": 0, "orange": 32, "pear": 15}
for key in prices:
print key
print "price: %s" % prices[key]
print "stock: %s" % stock[key]

Works perfectly now....


print "prices: %s" % prices[key]

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


Cool. Glad you got it working! Code on!


Had the same error, and for me it was a capital.


Literally for like 20 minutes I was like wtf then I checked this out and was like SERIOUSLY CAPITAL LETTER!!! lol


I had exactly the same issue, however, my problem was that I wrote
"price: %s " instead of "price: %s"


Those punctuation "errors" drive me freaking crazy! I have the habit of capitalizing the beginning of most words... I end up stuck on a lesson for a ridiculously long amount of time lmao.


I know this conversation is old but I was recently using it - while the code now works why is it that "price: %s" % price[key] works. Why does the first "price" need to be singular?


Having errors like this cost me 20 minutes of frustration is a bit annoying. Because I like to have proper capitalization on my output I am punished :frowning:


that's actualy pathetic....