Making a purchase


#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 key in food :
total += food[key]
return total

above is what i code ,but it doesn’t work.


Making purchase, returning a value that I don't understand why it does
#2

food is a list of products (like shopping_list), so here:

total += food[key]

you want to add the price of item/key to total, not sure how food is going to help with that.


#3

ok,thanks.i understand


#4