11/13 please help


#1

shopping_list = [“banana”, “orange”, “apple”]

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

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

Write your code below!

def compute_bill(food):

total = 0

for item in food:

total = total + prices[item]

return total 

the error i received is :

“compute_bill([‘banana’, ‘apple’, ‘orange’, ‘pear’]) returned 4 instead of 10.5”


#2

Check the indentation on your return line. The statement should not be in the loop.


#3

Simple like that, :slight_smile:

Thanks a lot!!!


#4

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