Skip to content

Instantly share code, notes, and snippets.

@scottsbaldwin
Created March 26, 2020 22:14
Show Gist options
  • Save scottsbaldwin/9699f0b02abd8fee76abd75c10297c2c to your computer and use it in GitHub Desktop.
Save scottsbaldwin/9699f0b02abd8fee76abd75c10297c2c to your computer and use it in GitHub Desktop.
Python - process list items in batches
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