Spaces:
Running
Running
| 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 | |