Making A Purchase....HELP!


I need help with my code for exercise 11....HELP!

Error message: "Oops, try again. compute_bill(['banana', 'apple', 'orange', 'pear']) returned 8.5 instead of 10.5"

It totals to 8.5 versus 10.5....

def compute_bill(food):
    total = 0
    for mark in food:
        if stock[mark] >= 0:
            total += prices[mark]
            stock[mark] -= 1
    return total


Woah there. You did what you need for exercise 12, not 11. You have it right--if you were on 12.
For 11, try this

def compute_bill(food):
    total = 0
    for key in food:
        total += prices[key]
    return total


what does the += sign do specifically? what does it mean?


PS thanks for the help swordsdance!


lets look at it this way
a += 10
also means
a = 10 + a
and yeah you're welcome don't forget to mark the comment as the solution


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