Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Even the Last by Sunshine_in_Winter
def checkio(array: list[int]) -> int:
# define a variable to store the sum of elements with even index
sum_number = 0
if len(array) == 0:
return 0
for i in range(0,len(array)):
if i % 2 == 0:
sum_number += array[i]
return sum_number * array[-1]
print("Example:")
print(checkio([0, 1, 2, 3, 4, 5]))
# These "asserts" are used for self-checking
assert checkio([0, 1, 2, 3, 4, 5]) == 30
assert checkio([1, 3, 5]) == 30
assert checkio([6]) == 36
assert checkio([]) == 0
print("The mission is done! Click 'Check Solution' to earn rewards!")
Aug. 22, 2025
Comments: