You are not logged in. Please login at to post your questions!


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):
for p in ti[1:]:

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

asked 20 May '17, 01:39

santh_chi's gravatar image

accept rate: 0%

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

Try this :


answered 20 May '17, 02:04

ellipse0934's gravatar image

accept rate: 0%

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 :(


answered 20 May '17, 11:31

trish16's gravatar image

accept rate: 0%

toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:


question asked: 20 May '17, 01:39

question was seen: 110 times

last updated: 20 May '17, 11:31