I hope this question isn't a duplicate; I found similar ones but not exactly what I need.
I want an efficient way to split a list into n sublists where each index goes to a different list until we reach the nth index and then the next n indexes go to the lists we already have, in the same order, and so on...
For example, given the following list:
l = [1,1,1,2,2,2,3,3,3]
n = 3
In this case I need to split the list into 3 lists with this desired output:
[[1,2,3],[1,2,3],[1,2,3]]
I can make n for loops that will skip every nth step, but I'm sure there is a better way.