What`s wrong?


#1

shopping_list = ["banana", "orange", "apple"]

stock = {
"banana": 6,
"apple": 0,
"orange": 32,
"pear": 15
}

prices = {
"banana": 4,
"apple": 2,
"orange": 1.5,
"pear": 3
}

Write your code below!

def compute_bill (food):
total=0
for item in food:
total=total+prices[item]
return total


#2

a function ends the moment a return keyword is reached.

If a return keyword is reached in a loop, to end the function, the loop has to break

In other words, your loop ends in its first iteration, rather then making all iterations


#3

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