我该如何编写一个程序来创建一个整数列表,要求用户输入一个新数字,直到引入零。
for example
Enter elements for a list, one at a time. Enter 0 to stop.
element = 9
element = 3
element = 1
element = -7
element = 2
element = 0
Finished getting user input.
The list is: [9, 3, 1, -7, 2]
这就是我所拥有的。
listA = [9, 3, 1, -7, 2]
while True:
input = int("some number: ")
if input == 0
break
print("Finished getting user input")
print("the list is: [9,3,1,-7,2]")
else:
listA.append(int(input))