Skip to content

Instantly share code, notes, and snippets.

@yono
Created May 24, 2010 13:55
Show Gist options
  • Save yono/411891 to your computer and use it in GitHub Desktop.
Save yono/411891 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# -*- coding:utf-8 -*-
def split_list(alist, n, newlist):
if len(alist) >= n:
newlist.append(alist[:n])
return split_list(alist[n:len(alist)], n, newlist)
else:
newlist.append(alist)
return newlist
alist = range(21)
print split_list(alist, 5, [])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment