Stocking Out - Any thoughts?


Continuing the discussion from 12. Stocking Out:


In your compute_bill function
you will want to collect the prices of all elements in your shopping_list

In your original-post, your for in-loop will exit
right after the variable total has been incremented
with the price of the first Element of your shopping_list
as it encounters the return statement.
The second Element is NOT inspected.
So you will have to change the compute_bill function

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

I have commented-out the decrement of the stock-item....
as i think they do not want to do that yet...