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

前端 未结 7 1811
[愿得一人]
[愿得一人] 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:42

    Leaving out the end still works when you want to skip some:

    range(10)[3::2] => [3, 5, 7, 9]
    

提交回复
热议问题