chef and dolls- iam getting NZEC error

T=input()
N=input()
ti=[]
ti.append(0)
n=[]
for i in range(T):
for j in range(N):
ti.append(input())

for k in range(max(ti)+1):
    n.append(0)
for p in ti[1:]:
    n[p]=n[p]+1

for q in range(1,(max(ti)+1)):
    if n[q]%2!=0:
        print q

I don’t know python so can’t really read your code. Are you sure the way you take input is correct ?

Try this : https://discuss.codechef.com/questions/7593/why-do-i-get-an-nzec?sort=votes&page=1

I guess that you are using the latest version of the python that is python3.4. When you are taking input by input(), you will get a string type data instead of integer type data. Thus your list ti is actually a list of string, not a list of integers. And as the index of a list should be integer not a string, you are getting a NZEC error at the line n[p]=n[p]+1. Because p here is a string, but should be an integer.

To get an integer input do int(input()). It will change the input type from string to int.

But if you use previous version of python i.e. python2.7, the code will run without any error. Many things have been changed in python3.4 in comparison with python2.7 :frowning: