What does list[x::y] do? [duplicate]

It slices

x[startAt:endBefore:skip]

if you use skip = 2, every other element the list beginning at startAt and ending at endBefore will be selected. [Remember: indices live BETWEEN list elements]

To see this, enter

x = range(100)

at the Python prompt. Then try these things

x[::2]
x[::3]
x[10:40:6]

and see what happens.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)