Light Mode
Dark Mode
Why does one work but other does not?

can someone explain why this code works:

def checkio(array):

for x in range(0, len(array), 2):

  return sum(array[::2]) * array[-1]

if len(array) == 0: return 0

but this does not?:

def checkio(array):

return sum(array[::2]) * array[-1]

if len(array) == 0: return 0

I guess i just dont understand why the for loop is there or why x isnt defined anyplace

Created: Jan. 30, 2020, 11:15 p.m.
Updated: Jan. 31, 2020, 12:58 a.m.
0
6
User avatar
nkarl480