# A day at Supermarket - Lesson 9

#1

I cant compiler code.

prices = {
"banana" : 4,
"maca"  : 2,
"laranja" : 1.5,
"pera"   : 3,
}
stock = {
"banana" : 6,
"maca"  : 0,
"laranja" : 32,
"pera"   : 15,
}

for key in prices:
print key
print "price: %s" % prices[key]
print "stock: %s" % stock[key]

total = 0
for x in prices:
s = prices * stock
print (s)
total = s + total
print (total)

#2

Hi, @don_biel ,

You have this loop header ...

for x in prices:

Inside the loop you should use x as a key to the prices and stock dictionaries. But you have this ...

s = prices * stock

You omitted the key, x, which should be placed in square brackets to access the two dictionaries, in a manner similar to what you did in the previous loop with the variable, key.

#3

Thanks, i think you may help me in other doubt.

Below,I need send 4 values to function, but when i send, ask the word food.

def compute_bill(food):
total=0
for x in food:
if stock[x] > 0:
total += stock[x]

print (compute_bill(food[x]))

#4

Hi, @don_biel ,

Due to the definition of the compute_bill function that you have programmed in your code, food is a parameter of the compute_bill function. Therefore, when you call the function, whatever list you pass to it as an argument will be represented as food inside the function.

At the beginning of your code, before the definition of the compute_bill function, you should have this assignment ...

shopping_list = ["banana", "orange", "apple"]

Then, after the function definition, you can call it, as follows ...

print compute_bill(shopping_list)

You will need to use the above line instead of this one, which is incorrect ...

print (compute_bill(food[x]))