- 1
BREAK IN LOOPS exercise question in Python
How do I solve this? Thanks. items = [] while True: n = int(input()) items.append(n) Change the code to end the loop when the user enters 0. Output the resulted list after the while loop ends. Sample Input 1 2 3 0 Sample Output [1, 2, 3]
1 Respuesta
+ 4
items = []
while True:
n = int(input())
if n==0:
break
items.append(n)
print(items)