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)
I found it helpful to use the VS Code extension cph as it allows setting testcases (input & expected output). To read the input I used a sample from ideone.com :
from sys import stdin for line in stdin: n = int(line) if n == 42: break print(n)
a = int(input(" ")) while true : if a == 42: print (a) break;