## https://www.codewars.com/kata/equal-sides-of-an-array/train/python

import unittest

def find_even_index(arr):
    ind = [i for i, x in enumerate(arr) if sum(arr[:i]) == sum(arr[i + 1:])]
    return ind[0] if len(ind) > 0 else -1

test = unittest.TestCase()

test.assertEquals(find_even_index([1,2,3,4,3,2,1]),3)
test.assertEquals(find_even_index([1,100,50,-51,1,1]),1,)
test.assertEquals(find_even_index([1,2,3,4,5,6]),-1)
test.assertEquals(find_even_index([20,10,30,10,10,15,35]),3)
test.assertEquals(find_even_index([20,10,-80,10,10,15,35]),0)
test.assertEquals(find_even_index([10,-80,10,10,15,35,20]),6)
test.assertEquals(find_even_index(range(1,100)),-1)
test.assertEquals(find_even_index([0,0,0,0,0]),0,"Should pick the first index if more cases are valid")
test.assertEquals(find_even_index([-1,-2,-3,-4,-3,-2,-1]),3)
test.assertEquals(find_even_index(range(-100,-1)),-1)