I create several fragments of the [-WINDOW-i:-i]
list, where i
is between 32
and 0
:
vals = [] for i in range(32, -1, -1): vals.append(other_list[-WINDOW-i:-i])
When i == 0
, a piece of length 0 is returned:
other_list[-WINDOW-0:0]
I do not want to do this to solve this problem:
vals = [] for i in range(32, -1, -1): if i == 0: vals.append(other_list[-WINDOW:]) else: vals.append(other_list[-WINDOW-i:-i])
... because if I have many lists to add to vals
, it becomes messy.
Is there a clean way to do this?
shell source share