[start:end:step] when slicing the list.
a=[1,2,3,4,5]
a[:] #[1,2,3,4,5]
a[0:5] #[1,2,3,4,5]
with the same return value
a[::-1] #[5,4,3,2,1]
a[0:5:-1] #[]
For a[0:5:-1], the return value is changed by the empty list form.
If step is negative with certain values in start and end, I get a return value differently than expected, but I'm not sure how it's sliced.
python slice
© 2024 OneMinuteCode. All rights reserved.