Write a program to break a list into chunks of size N


Topic: Write a program to break a list into chunks of size N

Solution

l = [1, 2, 3, 4, 5, 6, 7, 8, 9]  
n = 4 
x = [l[i:i + n] for i in range(0, len(l), n)]  
print(x)



List all Python Programs