What 's the answer of "8.Keeping Track of the Produce" in lesson "A Day at the Supermarket" in unit 5?


#1

This is the task:
Print the answer in the following format:
apple
price: 2
stock: 0

This is my code:

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\n"%stock[key]

And this is the results:

orange
price:1.5
stock:32

pear
price:3
stock:15

banana
price:4
stock:6

apple
price:2
stock:0

None

I don't think there is any wrong with my code,but it returns:"Oops, try again. Check what your code prints for orange. It doesn't look quite right!"

What should I do to fix it up?And how to order them?


#2

Compare what you print to the format described.


#3

Functionally your code is correct. It outputs exactly what is requested. Unfortunately the scoring engine is very picky so the formatting of your output is throwing it off.

If you add a space after before each %s and remove \n it should work.


#4

Oh,you are so careful and kind!Your solution works well!


#5

Get it!Thanks a lot!


#6

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