[Python] Display grouped list of items from python list cyclically

Discussão em 'Python' iniciado por Stack, Fevereiro 26, 2025.

  1. Stack

    Stack Membro Participativo

    Given an array, number of items in a group, and number of groups, I need to print the array cyclically in a loop. Array -[1,2,3,4,5,6] No. of items in a Group - 4 Iterations (No. of groups) - 7

    Output should be:

    ['1', '2', '3', '4']
    ['5', '6', '1', '2']
    ['3', '4', '5', '6']
    ['1', '2', '3', '4']
    ['5', '6', '1', '2']
    ['3', '4', '5', '6']
    ['1', '2', '3', '4']

    Continue reading...

Compartilhe esta Página