Making A Purchase


I'm stuck on Making a Purchase. Am I missing something? Can someone help me figure out what's wrong, and why? I'm thinking I need to review for loops in general.

stock = {
    "banana": 6,
    "apple": 0,
    "orange": 32,
    "pear": 15
prices = {
    "banana": 4,
    "apple": 2,
    "orange": 1.5,
    "pear": 3

# Write your code below!
def compute_bill(food):
    total = 0
    for item in food:
        total += prices
print total.

I keep getting this error: Oops, try again. compute_bill(['apple']) resulted in a TypeError: unsupported operand type(s) for +=: 'int' and 'dict'


this bit of your code:

for item in food:
    total += prices

you create a for loop to give you a variable (item) which holds the keys you need to access the values in your prices dictionary. You need to use the dictionaryname[keyname] to access the prices, which you can add to total


Thank you! Your description helped a lot!