# A day at supermarket (Code Academy Lesson) [Solved]

#1

I have done everything as instructed on the left side but still it shows the error message that:

“Check what your code prints for orange. It doesn’t look quite right!”

Can anyone help me out that why it is showing this error message?

#2

Please show us your code so we may identify any issues or differences from what is expected.

#3

“”“Here is the code”""

``````prices = {
"banana": 4,
"apple": 2,
"orange": 1.5,
"pear": 3}

stock = {
"banana": 6,
"apple": 0,
"orange": 32,
"pear": 15}

for items in prices:
print(items)
if items == "orange":
print("price: %.1f" % prices[items])
print("stock: %d" % stock[items])

elif items != "oranges":
print("price: %d " % prices[items])
print("stock: %d " % stock[items])
``````

#4

In different compiler it shows different outputs, i mean - when i execute it to my python shell it works fine but whenever i am submitting to codeacademy it prints the price and stock of “orange” in the first line and shows the error.

#5

Chances are there are not many error messages on store so the error has nothing to do with oranges. That would be a wild goose chase for sure.

No conditionals needed.

``````for items in prices:
``````

It would seem more apt to use `item` since it is singular, after all.

The lesson check may not expect added whitespace, or decimal format. Since the values are integers, present them as such.

``````print "stock: %d" % stock[item]
``````

or,

``print "stock: %i" % stock[item]``

#6

I am using the conditional (if) statement because the price of the item “orange” is in decimal form, and thanks for your kind informations.

#7
``````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: %d" % prices[key])
print("stock: %d" % stock[key])
``````

i just tried like this and still gives me the same error:

“”“Check what your code prints for orange. It doesn’t look quite right!”""

#8

It would appear that in both the cases above we have overlooked the string casting option. Look to the exampke in the lesson text. Perhaps that might lend a clue.

#9

Solved. Thanks everyone.

#10

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