fork download
  1. l = [1, 2, 3, 4, 5]
  2. chunk_size = 7
  3. batched_list = []
  4.  
  5. while l:
  6. chunk, l = l[:chunk_size], l[chunk_size:]
  7. batched_list.append(chunk)
  8.  
  9. print(batched_list)
Success #stdin #stdout 0.03s 9336KB
stdin
Standard input is empty
stdout
[[1, 2, 3, 4, 5]]