Last active
December 1, 2020 15:54
-
-
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.
This file contains 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 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