0
Python help!
Hi, I can’t understand why the answer to this is 5? Thank you! a = [x for x in range(4)] print(sum(a[2::-2] + a[::-3]))
3 ответов
+ 5
First you have : a == [0,1,2,3]
and a[2::-2] == [2,0] # -2 is the step in this case.
and you have also : a[::-3] == [3,0]
so a[2::-2]+a[::-3]==[2,0,3,0]
and the sum is 5
#for more precision
a[::-3] == [a[-1] , a[-4]]
a[2::-2] == [a[2] , a[0]]
a[::] == a
+ 1
YoPycode Thank you!
+ 1
K Kana You are welcome! Good luck 👍