Created
November 28, 2023 15:55
-
-
Save vhsu/ae87d412731be7c199577ccccaf537d4 to your computer and use it in GitHub Desktop.
Split arrays to smaller arrays in Python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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