Code resulted in 16 instead of the correct 7


#1

Umm this is my code and it is showing code resulted in 16 instead of the correct 7. Help please someone. I've been stuck here for a while.

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

Stocking Out
#2

You are accumulating to total twice. That line should be removed.


#3

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