lst=[] for i in range(0,5): ele=int(input()) lst.append(ele) for i in lst: if i==42: break else: print(i)
Well, try it on this test case:
1 2 3 4 5 6 42 99
It should print the numbers 1 to 6. Does it?
Thanks. I got it