Stocking Out


def compute_bill(food):
for item in food:
return total

Whats wrong with this?
Its showing error: "Oops, try again. calling compute_bill with a list containing 1 apple, 1 pear and 1 banana resulted in 0 instead of the correct 7 "


a function ends the moment a return keyword is reached, if the return keyword is reached in a loop, the loop simply breaks and the function ends


oh so do I need to return the total after the function?


no, return is only valid inside the function. You need to place return after the for loop


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