11. Oops, try again. compute_bill(['apple']) returned 7.5 instead of 2 HELP!


#1

Hi to all,

I don't know what's wrong...... Can someone help me???

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

stock = {
    "banana": 6,
    "apple": 0,
    "orange": 32,
    "pear": 15
}
    
prices = {
    "banana": 4,
    "apple": 2,
    "orange": 1.5,
    "pear": 3
}

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

print compute_bill(shopping_list)

The result is the same everytime, "Oops, try again. compute_bill(['apple']) returned 7.5 instead of 2".

Thanks in advance!!!

Regards.

David.


#2

The parameter variable is food

for key in food:

#3

Perfect!!!! Thank you so much!!!

Regards.

David.