Why this is incorrect?" Help on A Day at the Supermarket"


#1



Help on A Day at the Supermarket
in part ""Keeping Track of the Produce""


  


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]

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


#2

Can you show us your code and error message?


#3

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

I changed "prices" to "price" in print section it fixed:neutral_face:
Thanks


#4

Thank you Shiraz, your suggestion is what solved my problem


#5

Thanks Shiraz it solved mine too


#6

I have the same issue:
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" % stock[key]

output:
orange
price: 1.5
stock: 32
pear
price: 3
stock: 15
banana
price: 4
stock: 6
apple
price: 2
stock: 0
None

Thoughts?


#7

I've got it now,
print "price: %s"% prices[key]
print "stock: %s"% stock[key]


#8

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