#1

this completes the exercise

but the issue it doesnt return the prices of the items in the list "shopping_list" it just says "none" the question is does "total += prices[item]" add the values of the keys in the "prices" dictionary up? or no?

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

#2

Did you ever call your function, or did you only define it?

#3

i believe the return calls the function...could be wrong

these are directions

Define a function compute_bill that takes one argument food as input.
In the function, create a variable total with an initial value of zero.

For each item in the food list, add the price of that item to total.
Finally, return the total.

Ignore whether or not the item you're billing for is in stock.

Note that your function should work for any food list.

#4

The return will send the value to where you are calling the function.
You can call a function like this (depending on if it has parameters or not):

`myFunction()`
`myFunction(parameters)`

If you call the function this way

var variable = myFunction(something)
the value returned by myFunction will be stored into 'variable'

#5

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