Reputation: 17
So far my code below:
A=[]
while True:
B = int(input("Input a continuous amount of integers"))
A = [B]
print(A)
if B == -1:
break
else:
continue
Upvotes: 0
Views: 1353
Reputation: 2977
In Python, we call the this []
datatype as list
. To append item into a list, you can do A.append(B)
A = []
while True:
B = int(input("Input a continuous amount of integers"))
if B == -1:
break
else:
A.append(B) # modify this line
print(A)
Upvotes: 1
Reputation: 8558
You need to check if user input is -1
before appending it to the array and print it in the if
block, append it in the else
block.
A=[]
while True:
B = int(input("Input a continuous amount of integers"))
if B == -1:
print(A)
break
else:
A.append(B)
Upvotes: 0