0
I need help with some python code. And someone please explain to me how the output is 13 [solved]
x=[6, 4, 2, 9] x=x[::-1] print(x[0]+x[2])
4 Respuestas
+ 9
The second line reverses the list thus x becomes [9,2,4,6]
The value of x[0] is 9 while x[2] is 4 so their sum is 13
+ 5
::-1 basically reverses the list, so to see the indexes, count backwards. 9+4=13, so that's how you get the output.
+ 3
x=[6, 4, 2, 9]
x=x[::-1]
#now x is reversed -> x=[9, 2, 4, 6]
print(x[0]+x[2])
#first index + third index
#9 + 4
#= 13
+ 1
ans is
13