Making a purchase - how does the function know to look at the shopping_list?


#1

The correct code shown for this exercise is:
def compute_bill(food):
total = 0
for item in food:
total = total + prices[item]
return total

I’m confused how the correct code gets just the items in shopping_list.


#2

It will know it by what we pass into the function through its food parameter.

compute_bill(shopping_list)

shopping_list is the argument of the function call.


#3

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