Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First "Even the Last" solution in Clear category for Even the Last by olgag
def checkio(array: list) -> int:
"""
sums even-indexes elements and multiply at the last
"""
# Return 0 for empty array
if not array:
return 0
# Get all even indexes
ind_list = list()
for ind in range(len(array)):
if not ind%2:
ind_list.append(ind)
# Sum eleme with even indexes
sum = 0
for ind in ind_list:
sum += array[ind]
return sum * array[-1]
Feb. 5, 2021