Keeping Track of the Produce


#1



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


I not sure what's wrong. It's printing
{'orange': 1.5, 'pear': 3, 'banana': 4, 'apple': 2}
Price:1.5
Stock:1.5
{'orange': 1.5, 'pear': 3, 'banana': 4, 'apple': 2}
Price:3
Stock:3
{'orange': 1.5, 'pear': 3, 'banana': 4, 'apple': 2}
Price:4
Stock:4
{'orange': 1.5, 'pear': 3, 'banana': 4, 'apple': 2}
Price:2
Stock:2
None

also how can i just print the name of the fruit.
Thanks in advance


Replace this line with your 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 prices
    print"Price:%s"% prices[key]
    print"Stock:%s"% prices[key]


#2

Examine the example at left (in the lesson text). Our output needs to be exactly the same.

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

#3

Ok i figured out what was wrong. I cant capitalize the words "Price and Stock". But i dont get why that makes a difference. if it is in the "". Can anyone tell me why? thanks in advance.


#4

It is not an issue with the code, as such, just the lesson checker. It expects exactly one pattern, and will not accept any others.


#5

@kentmjk ,

Yeah, part of the Codecademy experience is getting some practice in following instructions. Though your code may be fine as far as the Python interpreter is concerned, if you have not followed the exercise instructions precisely, Codecademy's Submission Correctness Test (SCT) is likely to get after you. :fearful:


#6

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