I need help with this code


#1

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]

`


#2

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

#3

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.


#4

Regardez.


#5

It's still not working.


#6

Not working, or not passing?


#7

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

this code worked


#8

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.


#9

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