Code Correct, Still Not Running


#1



I don't see anything wrong with my code, but apparently there is something not right. Does anyone know what it could be?


This is the error message I am getting:
"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 i in prices:
    print i
    print "prices: %s" % prices[i]
    print "stock: %s" % stock[i]


#2

here:

print "prices:

a product has a price:, not prices:

the output needs to be an exact match


#4

my code reads :
prices = {
"banana": 4,
"apple": 2,
"orange": 1.5,
"pear" : 3
}

stock = {
"banana": 6,
"apple": 0,
"orange": 32,
"pear" :15
}

for i in prices :
print i
print "price: %s " % prices[i]
print "stock: %s " % stock[I]

it outputs:
orange
price: 1.5
stock: 32
pear
price: 3
stock: 15
banana
price: 4
stock: 6
apple
price: 2
stock: 0
None

But I still get :Oops, try again. Check what your code prints for orange. It doesn't look quite right!
Why?? Thanks


#5

you have a a space after %s which shouldn't be


#6

Thanks. Is that a Python requirement? Or is it the codeacademy?


#7

A codecademy requirement, the output needs to be an exact match to the example given in the lesson


#8

thanks for your help


#9

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