[英]How to take all elements except the first k
I'm very new to python and trying to write a concise list-comprehension. 我是python的新手,正在尝试编写简洁的列表理解。 Here is what I currently have:
这是我目前拥有的:
def __to_list(i):
#return some list
k = 3
some_list = #...
result = [e
for el in some_list
for e in __to_list(el) if #take all elements in __to_list(el) except the first k]
What is the pythonic way to do this? pythonic的方法是什么?
您可以只使用切片。
result = some_list[k:]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.