Skip to content

Instantly share code, notes, and snippets.

@johnbumgarner
Last active December 1, 2020 15:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnbumgarner/cb6d586b362584f37e9db18be0a4bcb2 to your computer and use it in GitHub Desktop.
Save johnbumgarner/cb6d586b362584f37e9db18be0a4bcb2 to your computer and use it in GitHub Desktop.
This Python function is used to divide a list into individual chucks based on a maximum length variable.
def divide_list_into_chunks(input_list, len_of_chunk):
"""
This function will divide a list into chunks.
:param input_list: list to divided
:param len_of_chunk: maximum length of each chunk
:return:
"""
for i in range(0, len(input_list), len_of_chunk):
yield input_list[i:i + len_of_chunk]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment