+ 2
What is the Output of this Code, And explain why it Outputs from 1 to 64
squares = [0, 1, 4, 9, 16, 25, 36, 49, 64, 81] print(squares[1:-1])
1 Resposta
+ 5
List slicing notation: [start:stop:step]
It includes start value while stop isn't included.
Also, index value of -1 gives the last element of the list.
So, [1:-1] is same as [1:9].
Hence, it returns [1,.....,64]