NZEC error in python

def count(a,b):#a's presence in b
n = 0
for i in range(len(b)):
if a == b[i]:
    n += 1
return n

def comb(i,j):
if i == j:
return 1
elif j == 1:
return i
else:
c = comb(i-1,j-1) + comb(i-1,j)
return c

T = int(input())
for i in range(T):
N,K = map(int, input().split(" "))
A = list(map(int,input().split(" ")))
A.sort()
B = A[:K+1]
Z = B[-1]
cntZ = count(Z,B)
Y = count(Z,A)
print(comb(cntZ,Y))

why am i getting nzec error in this? works fie in my ide. please help

Write your code in

try:
#your code
except Exception as e:
pass

Try this one

try :
def count(a,b):#a’s presence in b
n = 0
for i in range(len(b)):
if a == b[i]:
n += 1
return n

  def comb(i,j):
  if i == j:
  return 1
  elif j == 1:
  return i
  else:
  c = comb(i-1,j-1) + comb(i-1,j)
  return c

  T = int(input())
  for i in range(T):
  N,K = map(int, input().split(" "))
  A = list(map(int,input().split(" ")))
  A.sort()
  B = A[:K+1]
  Z = B[-1]
  cntZ = count(Z,B)
  Y = count(Z,A)
  print(comb(cntZ,Y))

except Exception as e:
pass

now it gives WA. so my code is wrong. anyway, thanks.

This just smothers the error and makes it harder to diagnose.

@infernusx9 - try with this testcase, with your original code (i.e. without the try-except):

1
10 5
3 3 3 3 3 3 3 3 3 3

python doesn’t give NZEC for no reason i’ve got it more than 25 times when i start codiung in python.don’t use try and except bcoz after that u will get wrong answer there must be some problem in list insexing like it might be going out of range or it can be anything try to do dry run for atleast 3 test cases.there is something wrong in your code