Skip to content

Instantly share code, notes, and snippets.

@vhsu
Created November 28, 2023 15:55
Show Gist options
  • Save vhsu/ae87d412731be7c199577ccccaf537d4 to your computer and use it in GitHub Desktop.
Save vhsu/ae87d412731be7c199577ccccaf537d4 to your computer and use it in GitHub Desktop.
Split arrays to smaller arrays in Python
def split(arr, size):
"""Splits an array to smaller arrays of size"""
arrays = []
while len(arr) > size:
piece = arr[:size]
arrays.append(piece)
arr = arr[size:]
arrays.append(arr)
return arrays
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment