Orange problems, shouldve been an apple guy


#1

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 "prices: %s"% prices[key]
print "stock: %s"% stock[key]

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


#2

You're supposed to print "price", not "prices".


#3

but price hasnt been wrote anywhere prior it asks for prices?!?!?!?!


#4

Traceback (most recent call last):
File "python", line 6, in
NameError: name 'price' is not defined

prices isnt it then?


#5

prices is the right list, but when you print it, you're supposed to print "price: " not "prices: "


#6

litterally how am i supposed to find that out thats mental ??


#7

also it doesnt work,

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 "prices: %s"% price[key]
print "stock: %s"% stock[key]

returns the same error regarding orange


#8

This...

Needs to be this...


#9

yeah i got it now seems like teh code was correct just codecademy being picky? or my error?


#10

The codecademy interpreter is picky. Sometimes you have to type EXACTLY what is says, capitalization and punctuation included.


#11

frustrating as ■■■■! thank you for youre persistence amigo


#12

Honestly, I don't feel like it's a bad thing. It's annoying, but it teaches you to copy verbose, and if you make a mistake, it helps you learn to find small things like an extra s or a period that it didn't ask for.


#13

And just to this blogninja and @tekkie1618 , the computer language python is very specific in how its wants its spacing, setup, and punctuation. For little grammar error or such can ruin a code in real life and it could have consequences so while it may be annoying it is for the better of the learner and the site :smiley:


#14

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