Well, I have this example:
mylist = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [0, 1, 2, 3, 4,
Well, you could do the same using list comprehension so at least it would get a bit shorter.
return [x[:5] for x in mylist]
Or if making your function a generator instead, you could also yield the individual elements:
for x in mylist: yield x[:5]