Runtime Error In Simple Python Code (nzec)
Solution 1:
Always try to at least run the code with the given example input:
$ python3 candy3.py < test.txt
Traceback (most recent calllast):
File "candy3.py", line 9, in<module>
x =int(input())
ValueError: invalid literal forint() with base 10: ''
Where candy3.py
contains the code from your question and test.txt
the following example input from the SPOJ assignment:
$ cat test.txt
2
5
5
2
7
3
8
6
7
11
2
7
3
4
If it doesn't run on your computer with the example input it most probably won't run on the SPOJ site with their real input.
Spoiler:
You are not ignoring the blank line before every test case but try to convert this blank line into a number.
Solution 2:
From here...
Basically you get nzec error or runtime error when your trying to access the array greater then its size or for some testcases your program may be running infinitely...
At the last , their might be some logical error in your code , try extreme test case in your code .
Since in spoj , the site is not maintained properly, for some question i tried i got tle in python and java but got AC in C and C++. This happen bcz the setter of the problem has not set the correct timing. This type of things have happen a lot to me .
Solution 3:
When we submit codes online, they give the input as a text file. Hence the inputs are in a single line. That's why we are getting NZEC error here.
Here, you might get it done by using raw_input().split() rather than using int(input()) in the first line
Post a Comment for "Runtime Error In Simple Python Code (nzec)"