【发布时间】:2013-09-30 10:59:30
【问题描述】:
def main():
COUNT = 1
food = []
n = int(input("Enter the number of items on your grocery list.\n"))
for i in range(1, n+1):
food.append = (input("What is item #" + str(COUNT) + " on your list?\n", sep=""))
COUNT = COUNT + 1
main()
我正在尝试将用户的输入添加到“食物”列表中。到目前为止,我有这个,但是当我运行它时,它给了我一个错误: TypeError: input() 没有关键字参数
有什么建议吗?
【问题讨论】:
-
只是一个建议,但我认为您不需要变量
COUNT,而是可以使用i代替COUNT。
标签: python list append typeerror keyword-argument