Please Help Me ! It always told me that Check what your code prints for orange. It doesn't look quite right!


#1

prices = {
"banana": 4,
"apple": 2,
"orange": 1.5,
"pear": 3
}
stock = {
"banana": 6,
"apple": 0,
"orange": 32,
"pear": 15
}
for key in stock:
print key
print 'price:',prices[key]
print 'stock:',stock[key]


#2

You can try this code at your side:

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]


#3

this too show same error. Code is ok but dont know why is this error showing


#4

Did you manage to solve this issue?


#5

Change "orange" to "oranges" and that works for some reason.
However, you will next get an error for pear which i don't know how to fix :confused:


#6

I think the problem come from the way you put spaces on your code.
print 'price:',prices[key]
print 'stock:',stock[key]


#7

while print we have to type price not prices. :slight_smile:


#8

I've encountered the same error prompt. Wondered if I should try different format instead of %s for the orange price. But so far no luck.


#9

yes, facing the same ridiculously irritating problem. they need to fix this. cant figure out whats wrong.


#10

Same Irritating problem again and again!!!! but no idea how to fix.Have already tried evertyhing in this thread!!!!!!! But nothing works


#11

just put price instead prices and its fine. well for me. :wink:

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

for cene in price:
print cene
print "price: %s" % price[cene]
print "stock: %s" % stock[cene]


#12

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