10. Making a purchase


#1

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

stock = {
"banana": 6,
"apple": 0,
"orange": 32,
"pear": 15
}

prices = {
"banana": 4,
"apple": 2,
"orange": 1.5,
"pear": 3
}

--> I'm having problem with this code cuz it says "It returned 4 Instead of 10.5" Pls help <--

Write your code below!

def compute_bill (food):
total = 0
for x in food:
total += prices[x]
return total


#2

Please re-edit your Post

  • select your code in the Post
  • then =click= on the </>-symbol-of-this-editor

Your code will then be in a pre-code state
and you will be able to make/present the proper indentations.


#3

def compute_bill (food):
total = 0
for x in food:
total += prices[x]
return total
it works