Created
January 24, 2017 10:24
-
-
Save ftorto/026c3d91fc66a571b923a8a9cf3d6df4 to your computer and use it in GitHub Desktop.
Split a list in chunk with python
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
list_to_chunk = [1,2,3,4,5,6,7,8,9,10] | |
number_of_items_per_chunk = 2 | |
for i in range(0, len(list_to_chunk), number_of_items_per_chunk): | |
print("CHUNK %s"%i) | |
chunk = list_to_chunk[i:i + number_of_items_per_chunk] | |
# Action to perform on each chunk here |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment