×

# chef and dolls- iam getting NZEC error

 0 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 '17, 01:39 6 accept rate: 0%

 0 I don't know python so can't really read your code. Are you sure the way you take input is correct ? answered 20 May '17, 02:04 21●3 accept rate: 0%
 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 4★trish16 1 accept rate: 0%
 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• 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:

×16

question asked: 20 May '17, 01:39

question was seen: 110 times

last updated: 20 May '17, 11:31