1

i'm new to python.i have been getting NZEC run time error for this code in codechef. i changed input() to raw_input().can someone explain to me why my code is getting a NZEC error

def function1(list1,sum):
if len(list1)==1:
    return sum
m=min(list1)
i=list1.index(m)
if list1.count(m)>1:
    sum+=list1.count(m)
else:
    sum+=1
list1=list1[:i]
return function1(list1,sum)

t=int(raw_input())
global list1
global sum
while t>0:
  n=int(raw_input())

  sum=0
  list1=list()
  list1[1:n]=raw_input().split()
  m=min(list1)
  i=list1.index(m)
  if i==0:
    if list1.count(m)>1:
        sum+=list1.count(m)
    else:
        sum+=1
    print(sum)
else:
    k=function1(list1,sum)
    k+=1
    print(k)
t-=1
1
  • NZEC means non zero exit code, in case of python that means a runtime error, please edit the indentation of your code. Commented Jul 2, 2017 at 17:39

2 Answers 2

0

You can do this this is solve my error.

put your all code in try and expect block.

This is solve my error.

try:
     ***your code***
 except:
        pass
Sign up to request clarification or add additional context in comments.

1 Comment

Hiding all errors and letting the code exit in an unknown state without showing that something wrong happened is never a good solution. It's just the worst thing to do!
0

(NZEC) I think you can't put custom input value in blank?

  1. Ple click on custom input button check tick...

  2. And write down some custom value on it in blank ... for test case

  3. after you click to run...

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.