Created
February 16, 2020 11:32
-
-
Save fahadahammed/998cd20cbd15d4f58afba1fc467a5e1e to your computer and use it in GitHub Desktop.
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 chunker(min_id, max_id, chunk_size): | |
list_of_number = list(range(min_id, max_id + 1)) | |
"""Yield successive n-sized chunks from lst.""" | |
for _oi in range(0, len(list_of_number), chunk_size): | |
yield list_of_number[_oi:_oi + chunk_size] | |
# Let you have 100 data in a list or tuple or array, | |
# But you want to use that data by chunk like 5 at a time or 10 at a time. | |
# This function will do that for you. | |
chunks = list(chunker(min_id=1, max_id=100, chunk_size=7)) | |
print(f"{len(chunks)} number of Chunks: {chunks}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment