Skip to content

Instantly share code, notes, and snippets.

@danielrmeyer
Created September 9, 2016 20:16
Show Gist options
  • Save danielrmeyer/a5d765ae7eb2da92fe3d758466c47f42 to your computer and use it in GitHub Desktop.
Save danielrmeyer/a5d765ae7eb2da92fe3d758466c47f42 to your computer and use it in GitHub Desktop.
chunk and flatten lists
def chunks(l,n):
return [l[i:i+n] for i in range(0, len(l), n)]
def flatten(l):
return [val for sublist in l for val in sublist]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment