列表索引必须是整数或切片

时间:2016-09-30 01:22:12

标签: python

NAME = 0
PRICE_PER_PERSON = 1
FAMILY_DEAL = 2
BEACH = 3





restaurant_list = [
# NAME              PRICE_PER_PERSON          FAMILY_DEAL          BEACH
["Olive Garden",    12.99,                      "Yes",             "No"],
["Big Boy",         12.99,                     "No",              "No"],
["Applebees",       9.99,                     "Yes",             "No"],
["Chili",           8.99,                    "Yes",             "Yes"],         
]



def isConsidered(restaurant):
    if restaurant_list[restaurant][BEACH] == "Yes":
        return True
    if restaurant_list[restaurant][PRICE_PER_PERSON]<10:
        return True
    if restaurant_list[restaurant][FAMILY_DEAL] == "Yes":
        return True


if __name__ == "__main__":
    your_choice = int(input ("what is the index number of the restaurant?     (0-4)")),
    if isConsidered(your_choice):
         print ("Yes, we like this restaurant.")
    else:
         print ("No, this restaurant is not good enough.")

嗨,我想让这段代码工作,但我不断收到错误消息“列表索引必须是整数或切片,而不是元组。”我可以得到一些帮助吗?

0 个答案:

没有答案