Apple + pear +banana = 9?


#1



I don't know if my code has a problem but If so I believe that for the moment that isn't the reason of this error message:

Oops, try again. calling compute_bill with a list containing 1 apple, 1 pear and 1 banana resulted in 9 instead of the correct 7

so if:
banana = 4
pear = 3
apple = 2

3+2+4=9

what is going on here?!

Here my code:

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

# Write your code below!

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


#2

Looks like you missed all of what the instructions say, so go have another look at that


#3

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