[Python] Split list into separate but overlapping chunks

Discussão em 'Python' iniciado por Stack, Agosto 12, 2025.

  1. Stack

    Stack Membro Participativo

    Let's say I have a list A

    A = [1,2,3,4,5,6,7,8,9,10]


    I would like to create a new list (say B) using the above list in the following order.

    B = [[1,2,3], [3,4,5], [5,6,7], [7,8,9], [9,10,]]


    i.e. the first 3 numbers as A[0,1,2] and the second 3 numbers as A[2,3,4] and so on.

    I believe there is a function in numpy for such a kind of operation.

    Continue reading...

Compartilhe esta Página