Light Mode
Dark Mode
I don't understand why error occours

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: Nov. 19, 2020, 9:23 p.m.
Updated: Nov. 20, 2020, 6:57 p.m.
0
9
User avatar
bressanvideo