# Compute_bill(['apple']) returned 7.5 instead of 2

#1

<Below this line, add a link to the EXACT exercise that you are stuck at.>

<In what way does your code behave incorrectly? Include ALL error messages.>
i think it counts too much prices
compute_bill([‘apple’]) returned 7.5 instead of 2
<What do you expect to happen instead?>

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

#2

the error message doesn’t reflect the code, which is slightly confusing.

lets add the function call the error message gives:

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

# function call
print compute_bill(['apple'])
``````

the function call represents a customer wants buy an apple, but gets charged for everything that is in shopping_list (which is: apple, banana and orange)

we are charging the customer for more then he is buying

#3

The function should acces each item in any food list given, not from shopping_list, and add the item price in total.

#4

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