Open this example in the interactive library
Source code
values = list(range(7))
print([values[i:i+3] for i in range(0, len(values), 3)])Sample output
[[0, 1, 2], [3, 4, 5], [6]]

Open this example in the interactive library
values = list(range(7))
print([values[i:i+3] for i in range(0, len(values), 3)])[[0, 1, 2], [3, 4, 5], [6]]