Partię listę Python

l = [1,2,3,4,5,6,7,8,9,10]
batch_size = 3    

for i in range(0, len(l), batch_size):
    print(l[i:i+batch_size])
    # i skip 3 (batch) on each itteration
    # l[0: 0+batch]
    # l[batch: batch+batch] ... 

>>> [1,2,3]
>>> [4,5,6]
>>> [7,8,9]
>>> [10]
Hilarious Hawk