Making A Purchase....HELP!


#1



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


https://www.codecademy.com/courses/python-beginner-en-IZ9Ra/2/2?curriculum_id=4f89dab3d788890003000096


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


#2

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

#3

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


#4

PS thanks for the help swordsdance!


#5

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


#6

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