NZEC in Life, the Universe, and Everything

Why my code is showing NZEC

while True:
n=int(input())
if n!=42:
print(n)
else:
break

Put it in a try block
consider

1
2
3

you will have an exception because you’re attempting to read from empty input. Catch that and it won’t show NZEC.

1 Like

Or restructure your code to the following:

n = int(input().strip())
while n != 42:
    print("{0}".format(n))
    n = int(input().strip())

How to become good in coding ?

Thanks, bro :slightly_smiling_face: