I want to break a list into sub-lists of n elements. I could convert the list (after adding appropriate padding) to a numpy array, e.g.:
n = 20
L = [x for x in range(93)]
Lnp = np.array(L+[0]*7).reshape(-1,n)
Lgrouped = [g for g in Lnp]
but this is sub-optimal. What would be a good way to do this without numpy? (itertools comes to mind, but didn't seem to find a straightforward function...)