NZEC in ITGUY13

Can someone please tell me why this code is getting me runtime error NZEC.
Thanks in advance.

for _ in range(int(input())):

  k, n = [int(x) for x in input().split()]

  vals = [int(x) for x in input().split()]

  indx = [i+1 for i, v in enumerate(vals) if v == k]

  l = min(indx)

  r = max(indx)

  if l == r: print(-1)

  else: print(*[l,r])
for _ in range(int(input())):
    k, n = [int(x) for x in input().split()]
    vals = [int(x) for x in input().split()]
    indx = [i+1 for i, v in enumerate(vals) if v == k]
    if(len(indx) == 0):
        print(-1)
        continue
    l = min(indx)
    r = max(indx)
    if l == r: print(-1)
    else: print(*[l,r])

I hope this helps you :slightly_smiling_face:

You mean to say if there is no matching k in the vals, indx will have a length 0 and trying to get min or max of it will cause ValueError and will fail.
Got it thanks.