# 12.Stocking Out

#1

Hello.Keep getting this error whatever i do.
Oops, try again. calling compute_bill with a list containing 1 apple, 1 pear and 1 banana caused the following error: string indices must be integers, not dict
What's going on?

``````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(food):
total = 0
for item in food:
if item[stock] > 0:
total = total + prices[item]
stock[item] -= 1

#2

if stock[item] > 0:

#3

Hahahha LMFAO.FFS.Thanks

#4

I've lost my mind and way too much time on this exercise. I have looked up all the threads discussing this exercise, edited my code 15x to suggestions that worked for others, my indentation is correct, and no matter what I do I get the following error message:

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

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(food):
total = 0
for item in food:
if stock[item] > 0:
total += prices[item]
stock[item] -= 1

#5

Follow this way and keep spaces

def compute_bill(food):
____total = 0
____for key in food:
________if stock[key] > 0:
____________total += prices[key]
____________stock[key] -= 1