Tell me why the slice is reset when I take a negative index. And is it possible to bypass the restriction? I tried instead of taking the slice to take the numbers on the index and run iteration - also fails.
c = [1, 2, 3, 4, 5] x = [c[z-2:z+3] for z in range(len(c))] print(x) it turns out:
[[], [], [1, 2, 3, 4, 5], [2, 3, 4, 5], [3, 4, 5]] I would like to:
[[1, 2, 3], [1, 2, 3, 4], [1, 2, 3, 4, 5], [2, 3, 4, 5], [3, 4, 5]]