import ast sys input_str = sys.stdin.read() code example
Example: from sys import stdin
from sys import stdin
for line in stdin:
n = int(line)
if n == 42:
break
print(n)
from sys import stdin
for line in stdin:
n = int(line)
if n == 42:
break
print(n)