Python NZEC Runtime Error

def home():

x=[]

for number in range(0,4):

value = int(input('Enter the values for %dth element'%number))
x.append(value)

if x[2] - x[0] > 0 and x[1] - x[3] == 0:

print ('right')

elif x[0] - x[2] > 0 and x[1] - x[3] == 0:

print('left')

elif x[0]-x[2] == 0 and x[1] - x[3] > 0 :

print ('down')

elif x[0] - x[2] == 0 and x[3] - x[1] > 0 :

print ('up')

else :

print (‘sad’)

test_case= int(input(‘Enter the number of test cases’))

for no in range(0,test_case):

home()

I’m getting NZEC Error for this code. Someone please help! Thanks in advance

w = input()

print(w)

I am getting an nzec error for this code on the chef compiler, not IDLE

@srirammurali91 Make sure you are using Python 3.5 on codechef,using Python 2 will give NZEC as syntax for Python 2 is different.

2 Likes

I am getting NZEC on this, however it works fine in IDLE:

z=0
e=0
l=0
r=0
lis=[]
poss=[]
data=[]
times=input()

def getDay(n):
    if(n=="sunday"):
        s=0
    elif(n=="monday"):
        s=1
    elif(n=="tuesday"):
        s=2
    elif(n=="wednesday"):
        s=3
    elif(n=="thursday"):
        s=4
    elif(n=="friday"):
        s=5
    elif(n=="saturday"):
        s=6

    return s
    
for i in range(0,int(times)):
    data=input().split()

    z=(getDay(data[0]))
    e=(getDay(data[1]))
    l=(int(data[2]))
    r=(int(data[3]))
      
    for j in range(1,15):
        lis.append((7*j+e)-z+1)

    for j in lis:
        if(j>=l and j<=r):
            poss.append(j)

    if(len(poss)==0):
        print("impossible")
    elif(len(poss)==1):
        print(poss[i])
    else:
        print("many")
        
    list=[]
    poss=[]

Your suggestion to use raw_input() and print(), instead of sys.stdin.read() and sys.stdout.write() solved my problem.
Thank you!

last line should be num = int(sys.stdin.readline())

4 Likes

in your second option for print, poss[i] should be poss[0], probably.

I tried with the raw_input too… but not working …

test_case = input()
num = []
for i in range(test_case):
num.append(raw_input())

for i in num:
print next_palidro(i)

2 Likes

use:
temp = input()
a,b = temp.split(" ")
this will solve your problem as the first line of input i.e e.g if the input is 10 4
using a = input() will take the entire line as a string and not leave anything for b to take in input nad hence the problem

Hey I’m facing the same problem
My Code:
temp=input()
print(temp)
I’m using Python 3.6 still I’m getting NZEC. What should I do?

1 Like

Facing same issue in python 3.6 :
notc=input()
print(notc)
getting NZEC for above lines, really frustrating

I am also getting NZEC error when i am running below code.

num=[6,2,5,5,4,5,6,3,7,6]
t=int(input())
for i in range(t):
a,b=map(int,input().split())
c=a+b
count=0
while(c!=0):
rem=c%10
c/=10
count+=num[rem]
if(i!=n-1):
print(count)
else:
print(count,end=’’)

Can anyone please help me in correcting this error.

Please share your solution link or format your code correctly.
Use three backticks ``` before and after your code.

Example:

```
Code
```

Then it looks like:

num=[6,2,5,5,4,5,6,3,7,6]
t=int(input())
for i in range(t):
  a,b=map(int,input().split())
  c=a+b
1 Like

@ankitsinla In your code, you use undefined variable n
if(i != n - 1):

Hey I’m getting NZEC error in fir line i.e T=int(input())
Please Help

    T = int(input())
while T:
    T-=1
    N,M = map(int, input().strip().split(" "))
    f = list(map(int,input().strip().split(" ")))
    p = list(map(int,input().strip().split(" ")))
    arr = [0]*M
    for i in range(0,N):
        arr[f[i]] = arr[f[i]] + p[i]
    
    arr.sort()
    for j in arr:
        if j != 0:
            print(j,end="")
            break

Have you provided custom input?

1 Like

It is happened because you probably didn’t use custom input while compile.

Thank you, this helped me.

I am getting NZEC for the following code at line 1.

inp = input()
inp = input().split(' ')
withdraw_amt, bal = float(inp[0]), float(inp[1])
if withdraw_amt%5 == 0 and withdraw_amt<bal:
    bal-=withdraw_amt+0.50
print('{:.2f}'.format(bal))

The complete error is:

Traceback (most recent call last):
File "./prog.py", line 1, in <module>
EOFError: EOF when reading a line

Are you trying to “Run” without Providing “Custom Input”?