Bug? A day at the Supermarket #8 Keep Track


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


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])

why is that? Cant runt it :S


Check the instructions again!

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:

price: 2
stock: 0

You have to make your output same as mentioned in point 2 of instructions.


I think that there is a problem with the decimal price of orange.
it prints it out as 1 and give back error

i modified the dictionary input as follows and it works:
prices = {"banana":4, "apple":2, "orange":1, "pear":3}
stock = {"banana":6, "apple":0, "orange":32, "pear":15}
for key in prices:
print str(key)
print "price: %d" % prices[key]
print "stock: %d" % stock[key]


I had this same problem for a day, until I was messing around with it and changed:
print ("Price: %s" % prices[key])
print ("Stock: %s" % stock[key])


print ("price: %s" % prices[key])
print ("stock: %s" % stock[key])

so all I did was lowercase and it worked, best of luck to you!


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