08 keep tracking of the produce


#1

prices ={
"banana": 4,
"apple": 2,
"orange": 1.5,
"pear": 3
}
stock ={
"banana": 6,
"apple": 0,
"orange": 32,
"pear": 15
}
for key in prices.viewkeys() & stock:
print key
print "prices: ", prices[key]
print "stock: ", stock[key]

the result is totally correct, but system says "show error during printing orange items", why? is it a bug?


#2

a product has a price, not prices

and use %s instead, i am afraid using a comma like you did might not possible


#3

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

Thanks a lot, I changed them according to you and it works, but I still can't understand where I made mistake, anyway, thanks and I'll check them again


#4

prices is just a name and it is given by system
and at first I used %s, the same error reported


#5

but i was talking about price here:
`
print "price

the string, you had prices, this should be price.

using , simply won't work because of how validation is done by codecademy.


#6

I understand finally, thanks a lot!
I ignored the different between "prices" and "price"


#7