NZEC error in python

Can anyone help me find out why is there a NZEC error in this simple code? All codes I’m writing in python are having error.

k=0
t = input("")

def rever(a):
    add = 0
    while a!=0 :
        c = a%10
        add = add*10 + c
        a = a/10
    return add

while k<t :
    x = input("")
    y = input("")
    val = rever(x) + rever(y)
    k = k+1

put

try: 
    your code here

except:
     pass

that should work

  1. You are not printing the output val anywhere.

2)Using Try catch is a bad practice and will give you WA if not NZEC. If x and y are both on the same line then do x,y= [int(u) for u in raw_input().strip().split()].If they are on different lines then Try replacing the input("") statement by input() or int(raw_input().strip())

I too am getting the NZEC error relentlessly, can someone please tell me what’s wrong with my code for this problem https://www.codechef.com/problems/CLEANUP :

try:
import sys
n, m = map(int,raw_input().split())
if n !=0:
if n>=m:
D = map(int,raw_input().split())
if len(D) == m:
A= list(range(1,(n+1)))
ToDo = set(A) - set(D)
ToDo = list(ToDo)
Chef = ToDo[::2]
Assistant = ToDo[1::2]

            print " ".join(map(str, Chef))
            print " ".join(map(str, Assistant))

except:
pass

You can have a look at my code in python it might help. https://www.codechef.com/viewsolution/13771228
. Also I don’t know abt python 3+ bt can u once check using int(input())

1 Like

typecast your input as input() take string