Shopping list no output, i need you help, god


#1

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

#2

该项目应该从源代码中删除。

This item should be removed from the source code.

给购物清单的功能…

Pass the shopping list to the function…

print (compute_bill(shopping_list))

#3

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