23
Oleksa Kushnir
Last seen 9 years ago
Member for 10 years, 3 months, 11 days
Difficulty Normal
You can use slices and sum here:
Your code
for i in range(len(array)):
if (i % 2) == 0:
x = x + array[i]
is equal to:
x = sum(array[::2])
More