Where i am wrong?


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 stock:
total += prices[item]
return total


you want to pass a list of fruits to the compute_bill function, loop through the list and check the price if it is in stock and compute the total but I'm your implementation you not using the argument food anywhere. Which means it will never matter the shopping list you pass to this function it will always compute the total of everything in stock


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