the problem is from codewars:
My code shows ValueError:
Traceback (most recent call last):
File “main.py”, line 3, in
Test.assert_equals(iq_test(“2 4 7 8 10”),3)
File “/home/codewarrior/solution.py”, line 8, in iq_test
i = int(i)
ValueError: invalid literal for int() with base 10: ‘’
Could you tell me what’s wrong with my code? Why it is showing ValueError? What changes should I make?
def iq_test(numbers):
even =[]
odd = []
for i in numbers:
i = int(i)
if (i%2) == 0:
even.append(i)
else:
odd.append(i)
if len(even) == 1:
for i in even:
index = numbers.index(i)
index = index + 1
return index
elif len(odd) == 1:
for j in odd:
index = numbers.index(j)
index = index + 1
return index