21 / 23
Apr 2021

I have tried many times.But this code is working in python 3.7 perfectly.

while 1>0 :
a = int(input( ))
if(a == 42):
break;
print(a)

3 months later

I found it helpful to use the VS Code extension cph2 as it allows setting testcases (input & expected output).
To read the input I used a sample from ideone.com2 :

from sys import stdin

for line in stdin:
    n = int(line)
    if n == 42:
    	break
    print(n)
5 months later