Whats wrong i cant print orange?


Replace this line with your code. 
    "banana": 4,
    "apple": 2,
    "orange": 1.5,
    "pear": 3
    "banana": 6,
    "apple": 0,
    "orange": 32,
    "pear": 15
for  x in prices:
    print x
    print "prices : %s" %prices[x]
    print "stock  : %s" %stock[x]


What's stopping you?

Your code has the following output:

prices : 1.5
stock  : 32
prices : 3
stock  : 15
prices : 4
stock  : 6
prices : 2
stock  : 0

So you very much seem to be able to print orange. Perhaps you're wondering about something other than what you're asking about? Make sure to ask for what you're after. Be specific!


@ionatan there a error which says orange is not printed


Dunno, maybe it's saying something other than what you say it says. Maybe you changed the meaning of the error message and that is causing you to look for a different problem than it's actually talking about?

For example, if it says you printed orange differently from what it expects, then that's not the same as not having printed it at all.

If it says you print it differently, then what can you do about that?


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


See. Entirely different. What can you do about it? What's stopping you from fixing that? It describes what is different about your program's behaviour.

You didn't consider what the error message said!


it prints the exact details idk what the problem maybe i willl see one more time


If it says it wasn't printed "quite right", then compare to what the instructions say is right. Right?


I have tried it out multiple times :sweat:


Have you compared what instructions describe to what you print?
There instructions include an example. Can you tell the example apart from what you print?

The instructions say to use the same format as that example. If you can tell them apart, then you didn't use the same format, or there would be no difference.


You need to have the : directly after price and stock in the print lines.no spaces after each word.

should look like this print "price: %s" print "stock: %s"


got it ! thanks this is crazy just a space made the whole difference :smile: @jonesandrewk @ionatan


hey.. the same problem for me.
I've entered the code like this-
print "prices: %s" %prices[x]
print "stock: %s" %stock[x]

but it's not working.
anymore spaces to avoid?


And that's why you should compare instead of jumping to the conclusion that the spaces are wrong. Compare your output to the described format.

If it's the same problem then the answer is the same. If the same answer doesn't apply, then it's not the same problem! You're making a whole lot of assumptions here, and it's hurting your reasoning!


I have the same problem too.


it worked bro.! the problem is not with our codes. It's this that codecademy only takes one type of output and returns error for all other outputs may it be correct or not. Just check my code, i'm dropping it below. :wink:
prices = {'banana':4,'apple':2,'pear':3,'orange':1.5}

stock = {"banana":6,'apple':0,'pear':15,'orange':32}
for x in prices:
print x
print "price: %s" %prices[x]
print "stock: %s" %stock[x]

here, in the 2nd print command, it would be written prices. go change that to price. I have changed it in mine, so just copy paste and try this code. it will surely work.


Yeah, I had a similar problem. I have an unrelated question, though. Why does oranges print first, instead of banana?


Hi @scriptplayer61355 ,

A brief answer to that unrelated question is on this page: A Day at the Supermarket: This is KEY!.

A Python dictionary is an example of a hash table. For lots of details, perhaps more than you asked for, see Wikipedia: Hash table. Hash tables are really cool and very useful.


The words "price" and "stock" must be written in small letters

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


The words "price" and "stock" must be written in small letters

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