Hi Gents. Anyway seen something like this?
I'm failing on the "check solution" part. Here is what my code is:
number_sequence = [-37, -36, -19, -99, 29, 20, 3, -7, -64, 84, 36, 62, 26, -76, 55, -24, 84, 49, -65, 41]
def checkio(array):
summ = 0
for i in array:
if (array.index(i)) % 2 == 0:
summ = summ + i
print('index: ', array.index(i), 'element:', i )
if len(array) >= 1:
product = summ * array[-1]
else:
product = 0
return product
print(checkio(numbersequence))
print(numbersequence[16])
print(16%2)
And the result:
%Run ciorna.py
index: 0 element: -37
index: 2 element: -19
index: 4 element: 29
index: 6 element: 3
index: 8 element: -64
index: 10 element: 36
index: 12 element: 26
index: 14 element: 55
index: 18 element: -65
-1476
84
0
What is going on? Why does the iterator skip over 16?
Created at: 2022/08/07 19:50; Updated at: 2022/08/07 20:00