shopping_list = ["banana", "orange", "apple"]
stock = {
"banana": 7,
"apple": 1,
"orange": 33,
"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
return total
compute_bill(shopping_list)
gaaay can't paste with correct indentation
stock = {
"banana": 7,
"apple": 1,
"orange": 33,
"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
return total
compute_bill(shopping_list)
gaaay can't paste with correct indentation
Last edited: