What is wrong with it?


#1



https://www.codecademy.com/courses/python-beginner-en-IZ9Ra/1/3?curriculum_id=4f89dab3d788890003000096

I am doing this exercice and always get this error, I do not why:
Oops, try again. Check what your code prints for orange. It doesn't look quite right!

Thanks you in advance!


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]


#2

Hi @digitalwhiz11064,

Compare the output from your code to the format of the output specified in the instructions. For your code to pass, it must match the specified format exactly.

As an example of the difference, for apple, the output should be ...

apple
price: 2
stock: 0

However, your code produces ...

apple
prices: 2
stock: 0

#3

This is Formatting mistake, Your code is fine.
Codeacademy's code output formatting just is not matching with your code.

There is just one minor mistake that @appylpye have mentioned.
I hope you already found the solution ?
If not...
then just tell me difference between price and prices?
I hope it helps!:slight_smile:


#4

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