What is the most efficient way to rotate a list in python? Right now I have something like this:
>>> def rotate(l, n): ... return l[n:] + l[:n]
It depends on what you want to have happen when you do this:
>>> shift([1,2,3], 14)
You might want to change your:
def shift(seq, n): return seq[n:]+seq[:n]
to:
def shift(seq, n): n = n % len(seq) return seq[n:] + seq[:n]