The problem of forward and reverse slicing of version 3.71 in Pycharm?

topic description

problems that do not correspond to forward and reverse slice indexes

sources of topics and their own ideas

I made my own attempt on the problem of slicing when I was learning the code today, and found a little problem

.

related codes

/ / Please paste the code text below (do not replace the code with pictures)
L =
print (L [- 5])
print (L [: 5])
print (L [- 5print (L 0mur1])
print (L

what result do you expect? What is the error message actually seen?

I think the result should be
0
[0 br > 0
[4 br > 0
]
[4
]

0
[0,1,2,3,4]
[]
[4,3,2,1]
[4,3,2,1,0]

Why is it that the index in positive order is 04th
, but the index in reverse order is not fully displayed until it is fully displayed?
but using L [- 6] alone shows that it is beyond list

Jan.20,2022

    The
  1. range is left closed and right open (regardless of the head and tail), that is, the first index element is contained in the shard, and the second is not included in the shard
  2. print (L
  3. ) is equivalent to print (L [0: 0: 1]).
  4. print (L [- 1 print] is equivalent to L [4: 0 print]
The interval of

slices follows the principle of opening before closing: if the index of positive order is 0 percent 4, then the interval is 0 percent 5; if the index of reverse order is-1 percent 5, then the interval is-1 percent 6.

Menu