Keeping Track of the Produce


#1



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

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

I expected it to list the item, the price and then the stock which it does, but shows me an error about the print for oranges. Im unsure of what i missed.


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

Instruction:
Print the answer in the following format:

apple
price: 2
stock: 0

now consider when you are printing the answer is it same format what the lesson wants ?

It should be exact same


#3

I believe you're right. I modified my code to say Prices and Stock instead of price and stock and it wouldn't accept it. You have to put it exactly as it says.


#4

I made my code almost like yours.

but for my "prints" firstly i put

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

And i had the same reponse

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

And i cahnged
my first print
I put

 print  key

and now it was accepted


#5

print "%s " %key

notice the space after %s that makes the difference


#6

Thank you all very much.


#21