File size: 362 Bytes
03a907a
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
def chunk_list(items: list[int], size: int) -> list[list[int]]:
    """Split a list into chunks of a fixed size."""
    if size <= 0:
        raise ValueError("size must be positive")

    chunks = []
    # BUG: drops the final partial chunk.
    for i in range(0, len(items) - size, size):
        chunks.append(items[i : i + size])
    return chunks