Блог пользователя Ali_BM

Автор Ali_BM, история, 8 лет назад, По-английски

Hello every one . I have solved a problem with python 2 but code forces shows me runtime error . could you please tell me how i can solve this problem with code forces ? The problem is : 25A This is my code :

n = input()
array = []
a1 = []
a2 = []
for i in range(0,n) :
	temp = input()
	array.append(temp)
	if array[i] % 2 :
		a1.append(i)
	else :
		a2.append(i)
if len(a1) < len(a2) :
	print a1[0] + 1, "\n"
else :
	print a2[0] + 1, "\n"
  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

»
8 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

your code should be like this version (difference is in input parts) :

n = input()
array = map(int, raw_input().split())
a1 = []
a2 = []
for i in range(0,n) :
	if array[i] % 2 :
		a1.append(i)
	else :
		a2.append(i)
if len(a1) < len(a2) :
	print a1[0] + 1, "\n"
else :
	print a2[0] + 1, "\n"

I suggest you to learn about differences between raw_input and input in python 2x