 # June Cook Off :ANKPAREN - NZEC in Python For

What causes NZEC in python
I submitted a code in python , i tested in Codechef IDE which gave appropriate output
when i submitted the same for the problem it gave me an NZEC

When i just wrote the same algo code in C++ 4.92 it gave me AC

Hi @geek_geek,

Only place i can see the posibility of error is using of del on the list on lines 38 and 43.

So try like this,

``````# your code goes here
def isval(s):
xy = 0
for i in s:
if(i=='('):
xy+=1
else:
xy-=1
if(xy<0):
return -1
if(xy==0):
return 1
else:
return -1
def prog():
s = raw_input()
#print "##",s
k = input()
if(isval(s)==-1):
if(k==1):
print s
else:
print -1
else:
nu = 0
l=len(s)
s=list(s)
wan = []
for i in xrange(l-1):
if(s[i]=='(' and s[i+1]==')'):
nu+=2
wan+=[(i,i+1)]
if(k>nu):
print -1
elif(k>(nu/2)):
k-=(nu/2)
k-=1
x=wan[-1::-1][k]
del s[x]
print "".join(s)
else:
k-=1
x=wan[k]
del s[x]
print "".join(s)
t = input()
for _ in xrange(t):
try:
prog()
except Exception:
pass
``````

If the solution doesn’t give NZEC, proramatically it wouldn’t throw NZEC, then we can focus on ‘del’ part try to handle it in different way if length of list greater than w then delete that element.

Apparently input data of the problem is not according to given format.
I too had a similar problem.