【发布时间】:2014-11-16 19:34:32
【问题描述】:
我必须编写一个程序,要求用户输入他们的购物清单,它应该要求他们输入他们的第一个项目,并在他们输入所有项目后输入“END”。
这是我目前的代码:
#Welcome
name = input("What is your name? ")
print("Welcome %s to your shopping list" %name)
#Adding to the list
shoppingList = []
shoppingList.append = input(print("Please enter the first item of your shopping list and type END when you have entered all of your items: "))
length = len(shoppingList)
#Output
print("Your shopping list is", length, "items long")
shoppingList.sort
print(shoppingList)
我不确定如何解决第二次添加到列表的问题,您能帮忙吗?谢谢。
【问题讨论】:
标签: python list python-3.x append