If i use a while loop instead of an if statement the following error message is observed:
Oops, try again. calling compute_bill with a list containing 1 apple, 1 pear and 1 banana resulted in 69 instead of the correct 7
I expected it to behave in the same manner an if statement would but seems i cant figure out the difference between the two. Can someone help??
def compute_bill(food): total=0 for item in food: while stock[item]>0: total += prices[item] stock[item] -= 1 return total