Keeping Track of the Produce


I keep getting an error message that says "Oops, try again. Check what your code prints for orange. It doesn't look quite right!" although I looked at other questions about the same exercise and I'm not sure what I'm doing wrong :confused: here's what I have:

prices = {
       "banana": 4,
       "apple": 2,
       "orange": 1.5,
       "pear": 3,

stock = {
       "banana": 6,
       "apple": 0,
       "orange": 32,
       "pear": 15,

for item in prices:
       print item
       print "prices: %s" %prices[item]
       print "stock: %s" %stock[item]


You probably printed something slightly differently, compare what you printed to the format shown in the instructions. It's about 20-30 characters so it's very reasonable to make an exact comparison by eye.


it looks pretty much the same to me :confused:


That's not enough when it needs to be exactly right


it does seem to be exactly the same


Did you compare character by character? One at a time? You must not have. Step up your comparison game.


.........yes, I did.


These are different:

prices: 1.5
stock: 32

price: 1.5
stock: 32

Looking at those I can immediately tell that the lines have different lengths. Your method of comparison needs to change.


You have to remove the "S" from "price:%s" not "prices:%s"

Correct answer:
print key
print "price: %s" %prices[key] -
print "stock: %s" %stock[key]


ohhh okay I see. I didn't realize that it would make a difference. thank you so much!!! :smiley:


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