Number 84 is in array 2 times. First in index 9, second in index 16 and this program doesn't add 84 in lst. I can't understand what i must change in program.
def checkio(array):
while True:
try:
lst = []
for i in array:
if array.index(i)%2 == 0:
lst.append(array.index(i))
sum1 = sum(lst)
sum2 = sum1 * array[-1]
return sum2
except IndexError:
return 0
print(checkio([-37,-36,-19,-99,29,20,3,-7,-64,84,36,62,26,-76,55,-24,84,49,-65,41,41]))
Created at: 2016/01/26 18:24; Updated at: 2016/03/03 09:57