11. Making a purchase- Help please!


#1



https://www.codecademy.com/courses/python-beginner-en-IZ9Ra/2/2?curriculum_id=4f89dab3d788890003000096

this message keeps appearing:
"Oops, try again. prices should contain {'orange': 1.5, 'pear': 3, 'banana': 4, 'apple': 2}"

Please tell me what is wrong with my 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
}

# Write your code below!
def compute_bill(food):
    total = 0
    for item in food:
        total += prices[item]
    return total
    
print compute_bill(shopping_list)


#2

Hi try to read my last post on that topic...


Hope that could help you


#3

hi. it seems that there was an error in the code for the lesson
the dictionary for prices came out:

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

instead of:

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

it was the double quotation marks rather than single that caused this error


#4

it was that

"pear ": 3

you have a space in the string
should be

"pear": 3