The problem of python step size

clipboard.png

list [- 1:] doesn"t this mean starting from the end? Why does the default step size of 0-1 mean 9
, but list [0: 4:] this step size represents 1?

Mar.20,2021

  1. step size defaults to 1, not 0;
  2. test [a li b], a, b two numbers only declare an interval, indicating that the value taken is within the interval of the source list, and the specific value is taken according to the step size. < / value >

you can refer to my article:
https://codeshelper.com/a/11.

.

list [- 1list:] step length is also 1
list [- 1br:] means starting with list -1 starting with a step size of 1 (the second step is followed by the step size, there is no default of 1), to the end (the first is the end position, and there is no default to the last element of the list), so take 9 first, and then take the list to end.
so return [9]

Menu