How do I go about writing a program that creates a list of integers that asks the user to enter a new number until zero is introduced.
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]
This is what I have.
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))
after this loop runs you have a list
mylistwhich contains all the integers the user input before he input0.