12/13 A DAY AT THE SUPERMARKET Stocking Out

Write your code below!

def compute_bill(food):
total = 0

for n in food:
   if stock[n] > 0:
      total += prices[n] 
      stock[n] -= 1
      return total

print(shopping_list)


it said "
calling compute_bill with a list containing 1 apple, 1 pear and 1 banana resulted in 4 instead of the correct 7
"

please help me about this😂i don‘t know how to fix it

move your return total line two tabs back so that it’s on the same indentation level as your for loop.

2 Likes