list1= [[1,2,3,4,5,6,7,8,9],[1,2,3,4,5,6,7,8,9],[1,2,3,4,5,6,7,8,9]]
Result should be:
list2 = [[1,2,3],[4,5,6],[7,8,9],[1,2,3],[4,5,6],[7,8,9],[1,2,3],[4,5,6],[7,8,9]]
This should work for any list divisible by 3 as well.
list1 = [1,2,3,4,5,6,7,8,9]
Result:
list2 = [[1,2,3],[4,5,6],[7,8,9]]
I tried using:
list2 = [list1[i:i + n] for i in range(0,len(list1),n)]
No luck.