• Even the Last(modulo doesn't work properly)

Question related to mission Even the Last



I'm a newbie who is trying to go through the quests. While I was doing the puzzles. I've encountered with a problem;

def checkio(array: list) -> int:

    total = 0
    if len(array) == 0:
        return 0
    for i in array:
        if array.index(i)%2 == 0:
            total = total + i
    a = array[-1]
    return total*a

This the code I've written to solve the puzzle but when I try to finish the quest this list gives an error. checkio([-37,-36,-19,-99,29,20,3,-7,-64,84,36,62,26,-76,55,-24,84,49,-65,41])

the code runs well until the 16. item =84, it passes through that one and continues to sum up the items then multiply the result with the last item on the list which gives me an error.

Whats the problem in here, Thanks