You are not logged in. Please login at www.codechef.com 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):
    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

asked 20 May, 01:39

santh_chi's gravatar image

1★santh_chi
6
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 : https://discuss.codechef.com/questions/7593/why-do-i-get-an-nzec?sort=votes&page=1

link

answered 20 May, 02:04

ellipse0934's gravatar image

3★ellipse0934
211
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 :(

link

answered 20 May, 11:31

trish16's gravatar image

3★trish16
1
accept rate: 0%

toggle preview

Follow this question

By Email:

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

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "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

Tags:

×15

Asked: 20 May, 01:39

Seen: 43 times

Last updated: 20 May, 11:31