[英]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.