+ 2
I didn't understand that code below
squares [0,1,4,9,16,25,36,49,64,81] print (squares [::2])
2 Respostas
+ 6
indexing is [start:stop:step]
The step is 2 so it'll print a list showing every other value in the list.
(default value for step is 1)
+ 3
slice default start index is 0, default end index (not included) is list length, step is 2... meaning the printed list will have the original list values at indexes 0, 2, 4, 6, 8...
so output is:
[0,4,16,36,64]