split array into chunks python

Solutions on MaxInterview for split array into chunks python by the best coders in the world

showing results for - "split array into chunks python"
Franco
20 Aug 2016
1a = [1, 2, 3, 4, 5, 6 ,7 ,8 ,9]
2
3splitedSize = 3
4a_splited = [a[x:x+splitedSize] for x in range(0, len(a), splitedSize)]
5
6print(a_splited)
7# [[1, 2, 3], [4, 5, 6], [7, 8, 9]]