A day at the supermarket - keeping track of the produce (ERROR MESSAGE)



> Oops, try again. Check what your code prints for orange. It doesn't look quite right!

the result in the console is as follows:but gives an error indicating the orange print out is incorrect while the code appears to be correct: the code is indicated below.

prices: 1.5
stock: 32
prices: 3
stock: 15
prices: 4
stock: 6
prices: 2
stock: 0

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


from the 2nd instruction
Print the answer in the following format:

price: 2
stock: 0

now check your code

prices: 2
stock: 0

it should be exact match


Thanks alot.. i rectified the small mistake. it worked.
But then why does such a small error on my part (spacing in this case) affect the functioning of whole program?


In your own environment you can do whatever you want but here you have to do what you are told to do.sometimes even a single space. here STC (sysyem checker) checks whether you've done or haven't what you are told.

so your code just fine .dont worry about it :slight_smile:

not just space.extra character :slight_smile:


Thank You:)) .It's helpful to know that


The code as listed works just fine for the exercise

But, isn't it still incorrect? Shouldn't the call for the string (%s) actually be a call for an integer (%i) or, in the case of the oranges a float (%f)?

I was stuck on this for a while because I thought using the %s would be incorrect.


your print is "price:2"
it should be "price: 2"
so it is "prices: %s" % prices[key]
not "prices:%s" % prices[key]


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