Bug? A day at the Supermarket #8 Keep Track


#1

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

code:

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


#2

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:

apple
price: 2
stock: 0

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


#4

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]


#5

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

to

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

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


#7

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