In Python, I can install endwhich I want in the snippet:
l = [0, 1, 2, 3, 4, 5]
l[:-1] = [0, 1, 2, 3, 4]
I can also set the necessary step:
l[::-1] = [5, 4, 3, 2, 1, 0]
So why can't I cancel a list that skips the last item at a time? I mean why this is happening:
l[:-1:-1] = []
To get the expected result using slices, I have to do:
l[:-1][::-1] = [4, 3, 2, 1, 0]
Does this have anything to do with field priority? The order in which actions occur during slicing?
source
share