Skip to content

Instantly share code, notes, and snippets.

@rikwatson
Created February 6, 2013 14:06
Show Gist options
  • Save rikwatson/4722706 to your computer and use it in GitHub Desktop.
Save rikwatson/4722706 to your computer and use it in GitHub Desktop.
# Split a list.
# Given [1,2,3,4,5,6,7,8] & 3 returns [[1,2,3], [4,5,6], [7,8]]
#
L = [1,2,3,4,5,6,7,8]
C = 3
print [L:[i:i+C] for i in range(0, len(L), C)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment