8. keeping track of product : floating number problem

I check my code several times and match with the other threads
and it looks alright.
prices= {“banana”:4,“apple”:2,“orange”:1.5,“pear”:3}

for fruit in prices:
print fruit
print “price: %d” %prices[fruit]
print “stock: %d” %stock[fruit]

The output for orange gives out “1”: instead of “1.5” for its price.
what could the mistake be?

Only difference i have with my code that works is that i used %s instead of %d.


You should get used to spacing your statements to make it easy to read.

Have you got your indentations right?

I have the similar problem :
Oops, try again.
Check what your code prints for orange. It doesn’t look quite right!

my code:
prices = {“banana”: 4,“apple” :2, “orange” : 1.5,“pear” : 3 }
stock = {“banana”: 6,“apple”: 0, “orange” : 32,“pear”: 15}

for x in prices:
print x
print “Prices: %s” % prices
print “Stock: %s” % stock

You can’t capitalize ‘prices’ or ‘stock’ or the code-checker will reject it.


i got this same problem

make sure you put “price” not “prices”
make sure you put everything in lower case

1 Like

i have already posed the question separately.

i have gone thru my code again and again…the same error about"orange"

The problem here is that I am not able to move forward to the next lesson.

is there a way out to skip this since I have understood the concepts.

1 Like

It took me some time to figure out what was wrong with my oranges.
It finally worked after I removed all the s from “prices” words.

Have you tried it too?


my code works fine with “%s” but it still throws an error
“Check what your code prints for orange. It doesn’t look quite right!”

Hi Can you post your code or creat a new Topic with your code and the error you get.

It works! But I wonder why

how ever i tried all the possibilities but can’t finf any solution please go through my script

for k in prices:
print k
print “prices: %s” % prices[k]
print “stock: %s” % stock[k]

Hi this part

print "prices:.....

you should remove the s from price
so it should be like that

print "price: %s" % prices[k]

i have pbm with orange but i found answer

for key in prices:
print key
print “price: %s” % prices[key]
print “stock: %s” % stock[key]


thank you dat was really helpful

thankyou that was really helpful

price not prices. took me way longer than i would like to admit to figure out.


Had the same problem, this worked! Thanks

I think it’s just the way Codecademy is evaluating the results. They want the answer to print as ‘price’ and not ‘prices’. I’m not sure why the error asks to look at oranges though. I think if your coding it will work, because the results are the same (besides the ‘s’.)