my code:
def checkio(array: list) -> int:
if len(array) == 0:
return 0
numeri =[x for x in array if array.index(x)%2 == 0]
risultato2 = 0
for x in numeri:
risultato2 += x
a = array[-1]
risultato = a * risultato2
return risultato
I have error on test 11.
Your result:-1476
41*(-37-19+29+3-64+36+26+55+84-65)
Right result:1968
Fail:checkio([-37,-36,-19,-99,29,20,3,-7,-64,84,36,62,26,-76,55,-24,84,49,-65,41])
I try manually with the calculator and the numbers are rights, but it seems that program makes an error.
Someone can explain me why?
Created at: 2020/11/19 21:23; Updated at: 2020/11/20 18:57
The question is resolved.