Sunday, November 2, 2008

99 problems - python - 17

Split a list into two parts; the length of the first part is given.

def split(lst, n):
return (lst[:n], lst[n:])

Trust me, these problems do get more challenging after a while. But it is a nice testament to the beauty of python how straightforward something like this is.

No comments: