Sunday, November 2, 2008

99 problems - python - 19

Rotate a list N places to the left.

def rotate(lst, n):
n = n % len(lst)
x, y = lst[:n], lst[n:]
return y + x

No comments: