比较python列表中的数字输入

时间:2019-05-01 18:58:15

标签: python list numbers numeric shopping

尝试创建列表。

TypeBasedCollectionResourceMapping

我可以通过某种方式编写代码,根据用户输入的数量来询问用户他们想要什么杂货。

类似

n = 0
while n = 0:
number = int(input ("What number of groceries do you wish to purchase?"))

只有这样,它才能打印多次...

1 个答案:

答案 0 :(得分:0)

不清楚您想要什么,但是您可以轻松完成


   <th class="font-parsibit">{{ $post->title != '' ? $post->title : 'No Post' }}</th>

示例输出为

number = int(input ("What number of groceries do you wish to purchase?"))
groceries = []

#Ask for grocery input number of times
for i in range(number):
    grocery = input("What grocery would you like to purchase?")
    groceries.append(grocery)

print(groceries)