【发布时间】:2015-02-19 02:16:07
【问题描述】:
最终,我想构建一个脚本,它接受用户的输入,不仅计算他们有多少输入,而且在最后的语句中重复它们。该脚本应该询问用户他们想将什么放入篮子中。用户满意后,他们可以输入“nothing”,这将停止循环并返回类似“篮子里有 x 个项目:item1、item2、item3”......等等。
我不知道如何计算每个输入,然后在最后一行使用确切的输入。
这是我目前所拥有的:
print('Add as many items to the basket as you want. When you are done, enter "nothing".')
print('What do you want to put into the basket now?')
while True:
myInput = input()
variable = 0
if myInput == "nothing":
print('There are' + str(variable) + ' items in the basket: [' + x + '.]')
break
else:
print('Okay, what else?')
variable += 1
如果有人能指出我正确的方向,那就太好了。
【问题讨论】:
标签: python python-3.x