Created
March 26, 2020 22:14
-
-
Save scottsbaldwin/9699f0b02abd8fee76abd75c10297c2c to your computer and use it in GitHub Desktop.
Python - process list items in batches
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
batch_size = 3 | |
l = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20] | |
while l: | |
s = l[:batch_size] | |
print(s) | |
l = l[batch_size:] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment