• "Even the last" elementary task


Task: You are given an array of integers. You should find the sum of the elements with even indexes (0th, 2nd, 4th...) then multiply this summed number and the final element of the array together. Don't forget that the first element has an index of 0. For an empty array, the result will always be 0 (zero). Input: A list of integers. Output: The number as an integer.

I don't understand where i could do a mistake in the following code:

def checkio(array):
        sums even-indexes elements and multiply at the last
    if len(array) == 0:
        print "0"
        a = sum(array[0:len(array):2])
        return a * array[-1]

I've checked the code via terminal and no mistakes there:

>>> def checkio(array):
...     if len(array) == 0:
...         print '0'
...     else:
...         a =sum(array[0:len(array):2])
...         return a * array[-1]
>>> checkio([])
>>> checkio([1, 2, 3])