test.py 378 B

123456789101112131415
  1. def split(arr: "list", batch: "int") -> "list[list]":
  2. size = len(arr)
  3. if size <= batch:
  4. return [arr]
  5. step = size // batch
  6. res = [arr[i * batch: (i + 1) * batch] for i in range(step)]
  7. if size % batch:
  8. res.append(arr[step * batch:])
  9. return res
  10. if __name__ == '__main__':
  11. ll = list(range(1, 29))
  12. print(ll)
  13. print(split(ll, 50))