While coding on various competing sites, many people must have encountered the NZEC error. NZEC (non-zero exit code), as the name suggests, occurs when your code cannot return 0. When the code returns 0, it means it succeeded, otherwise it will return some other number depending on the type of error.
When the program exits and is expected to return "0" to indicate that everything ran fine and is unable to do so, it calls NZEC. Of course, there are more NZEC-related cases.
Why is NZEC happening? (One example)
In python, typically multiple inputs are separated by commas and we read them using input () or int (input ()), but most online coding platforms during testing is given a space-separated input and in these cases int (input ()) cannot read the input correctly and shows an error like NZEC.
How to solve?
For example, imagine a simple program in which you have to read 2 integers and print them (in the input file, both integers are on the same line). Suppose you have two integers like below:
Instead of using:
n = int (input ()) k = int (input ( ))
n, k = raw_input (). split ("") n = int (n) k = int (k)
limit input to spaces.
Input data :
When you run the above code in the IDE with the above input, you will get an error: —
Traceback (most recent call last): File "b712edd81d4a972de2a9189fac8a83ed.py", line 1, in n = int (input ()) File "", line 1 2 3 ^ SyntaxError: unexpected EOF while parsing
The above code will work well when the input is on two different lines. You can test yourself. To overcome this problem, you need to use split.
Input data :
Output: stron g>
Some important causes of the NZEC error
There may be other causes of the NZEC error, I have listed common ones.
This article is provided by Aakash Tiwari . If you are as Python.Engineering and would like to contribute, you can also write an article using contribute.python.engineering or by posting the article [email protected] ... See my article appearing on the Python.Engineering homepage and help other geeks.
Please post comments if you find anything wrong or if you would like to share more information on the topic discussed above.