Wrong code for orange?



I put the correct code for orange, yet it says "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 key
    print "Price: %s" % prices[key]
    print "Stock: %s" % stock[key]


I am not this far in python but just in looking at the code does orange need to be in ' ' rather than " " like all the other fruits?


Sorry, I put ' and ' first but changed it due to the fact that it said wrong code for orange so i changed it to " and "

EDIT: i edited the post


Your code is working, but is not passing the exercise, because the exercise is expecting variables with exact names. Capital or lower case do matter.

Price and price are different.


I have the same issue and I have checked all variable names and they match exactly. I have refreshed my browser and this does not apper to solve the problem. I have a screenshot here of what is going on and how the problem

There does not seem to be anything that is able to solve the problem at the moment, has anyone got any help so that I can compleat this.


Your code is correct. However, codecademy seems to checks for the exact variable names so instead of "print prices" it should be "print price". It was the same issue with mine except I had a capital letter but yours needs to be price instead of prices


I'm having the same issue.

price = { "banana" : 4 ,
"apple" : 2 ,
"orange" : 1.5 ,
"pear" : 3 }
stock = { "banana" : 6 ,
"apple" : 0 ,
"orange" : 32 ,
"pear" : 15 }

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


When you were defining the dictionary for prices, you forgot the s and only put price ={} so when you tried % prices, python didn't know what prices was.


Thanks it works now. Glad I got that sorted now, spent ages on that one.


Thanks! I've been trying this forever.


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