![](/img/trans.png)
[英]How can I print an element from a list one by one starting by first element and increment until the last one in python
[英]How can I select elements of a list starting by a later element in the list to one that is before in python
我的問題是,如何 select 列表的多個元素,但從列表的后一個元素開始到之前的一個元素,例如:
list_1 = [1, 2, 3, 4, 5, 6, 7, 8]
list_2 = list_1[6:3]
print(list_2)
# Result
[7, 8, 1, 2, 3]
list_1 = [1, 2, 3, 4, 5, 6, 7, 8]
list_2 = list_1[6:]+list_1[:3]
print(list_2)
回報:
[7, 8, 1, 2, 3]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.