How to slice a list from an element n to the end in python?

前端 未结 7 1812
[愿得一人]
[愿得一人] 2020-12-29 01:24

I\'m having some trouble figuring out how to slice python lists, it is illustrated as follows:

>>> test = range(10)
>>> test
[0, 1, 2, 3, 4         


        
7条回答
  •  不知归路
    2020-12-29 01:27

    If you're using a variable as the range endpoint, you can use None.

     start = 4
     end = None
     test[start:end]
    

提交回复
热议问题