Keeping track of the produce: I am confuse!


#1

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

After running the code the result prints the right value for orange. I am confuse

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 "prices: %s" %prices[key]
print "stock: %s" %stock[key]


#2

instruction:

Like the example above, for each key, print out the key along with its price and stock information. Print the answer in the following format:

apple
price: 2
stock: 0

now check your format.is it same?


#3

How is it different please? I only added the 'print key' because I needed to make sure the answer appears as stated:

'apple'
price: 2
stock: 1.5


#4

Please help me understand how and where the error exist.


#5

your output looks like

apple
prices: 2
stock: 0

But it should be

apple
price: 2
stock: 0

can you see the difference?
It should be exact same.


#6

@mtf and @stetim94 help out here please


#7

Interesting.. So all I had to do was remove the 's' in price's' and it is solved.

I just tried it and it turned out correct. Why is that a problem?


#8

It's not a problem.system is checking whether you print the correct string or not.system is so strict(most of the time).sometimes a single space can create a problem.


#11