I need help with this code


for the excise given in "Keeping Track of the Produce" I tried to use this code but it seems it doesn't work. It keeps showing this message "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 "%s" %key
print "price:" + "%s" % prices[key]
print "stock:" + "%s" % stock[key]



Probably the only issue is the missing space character in the latter two lines. Is there such a thing as a double interpolation?

"price: %s" % prices[key]
  needed space


No that's not the issue, the console prints out everything ok but the error message keeps showing up and wont let me pass that stage. If you copy and paste the code you might see that the code actually works in printing the expected results.




It's still not working.


Not working, or not passing?


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

this code worked


I'm having the same issue. It is printing exactly what it shows in the example but it still says that orange is not right.


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