chunk_list(items, size) that splits items into consecutive sublists of length size. The final chunk may be shorter if len(items) is not a multiple of size. Assume size is a positive integer.items = [1, 2, 3, 4, 5, 6, 7], size = 3
[[1, 2, 3], [4, 5, 6], [7]]
Groups of 3, with a shorter final group.
Step through indices 0, size, 2*size, ... and slice items[i:i+size] each time.