[Python] Splitting a long tuple into smaller tuples

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

  1. Stack

    Stack Membro Participativo

    I have a long tuple like

    (2, 2, 10, 10, 344, 344, 45, 43, 2, 2, 10, 10, 12, 8, 2, 10)


    and i am trying to split it into a tuple of tuples like

    ((2, 2, 10, 10), (344, 344, 45, 43), (2, 2, 10, 10), (12, 8, 2, 10))


    I am new to python and am not very good with tuples o(2, 2, 10, 10, 344, 344, 45, 43, 2, 2, 10, 10, 12, 8, 2, 10)r lists. My friend said i should split it but i just cant get it -_-

    I need to split the tuple into tuples with 4 elements that i will later use a rectangles to draw to a image with PIL.

    Continue reading...

Compartilhe esta Página