Shopping list no output, i need you help, god


this is the lesson of unit 5 in codecademy: a day in supermarket
I do not have any output here. the code looks right.:disappointed_relieved:

#商品清单          # List of goods
shopping_list = ["banana", "orange", "apple"]
#库存              # in stock
stock = {  "banana": 6,  "apple": 0,  "orange": 32,  "pear": 15}
#单价              # unit price
prices = {  "banana": 4,  "apple": 2,  "orange": 1.5,  "pear": 3 }

#客户采购清单       # Customer purchase list
food = {'apple':2, 'orange':3, 'pear':6}

#客户计算花费       # Calculate the cost of the customer
def compute_bill(food):
   total = 0
  for item in food:
    if stock[item]>0:
      total = total + prices[item]
  print total



This item should be removed from the source code.


Pass the shopping list to the function…

print (compute_bill(shopping_list))


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