# Making a Purchase - Getting strange feed back

#1

Making a Purchase

my error message is:
Oops, try again. compute_bill(['apple']) returned 7.5 instead of 2
which makes no sense because it is returning the correct total

My code returns:
banana: 4
orange: 1.5
apple: 2
total: 7.5
None

``````Replace this line with your code.
shopping_list = ["banana", "orange", "apple"]

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

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

def compute_bill(item):
total = 0

for item in shopping_list:
total += prices[item]
print item + ": " + str(prices[item])

print "total: " + str(compute_bill(shopping_list))``````

#2

take a look at the instruction
Define a function `compute_bill` that takes one argument `food` as input.

so here

`def compute_bill(item):` # write `food` instead of `item`

next instruction
For each item in the food list.so now i would do

`for item in food:`

now do the rest

#3

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