lair of the dustbunny
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:
Post a Comment
‹
›
Home
View web version
No comments:
Post a Comment