Keeping Track of the Produce


#1



Keeping Track of the Produce


I keep getting this error message:
'Oops, try again. Check what your code prints for orange. It doesn't look quite right!'


prices={"banana": 4,
"apple": 2,
"orange": 1.5,
"pear": 3
}

stock = {"banana": 6,
"apple": 0,
"orange": 32,
"pear": 15,
}

for food in prices:
    print food
    print 'price: %s'% prices[food]
    print 'Stock: %s'% stock[food]


#2

This exercise is very strict about formatting.

Your one of the o/p should look like this..

orange
price: 1.5
stock: 32

Can you find any difference ?


#4

Thank you i needed help finding that!


#6

Your stock word starts with a capital letter instead of a lowercase letter. It is not consistent with your code up there.


#7

Wow. Thanks a lot! It was literally prices vs price


#8

My attempt:

prices = {
    "banana"    :   4,
    "apple"     :   2,
    "orange"    :   1.5,
    "pear"      :   3,
}

stock = {
    "banana"    :   6,
    "apple"     :   0,
    "orange"    :   32,
    "pear"      :   15,
}

once = {"a" : 1, "b" : 2}
twice = {"a" : 2, "b" : 4}

for key in prices:
    print  key
    print  "price %s"   % prices[key]
    print  "stock %s"   % stock[key]
    # prints the items in the list
    #print " %s" % stock[item] # prints the items in the list

#9

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