thorsten at thorstenkampe.de
Thu Sep 16 09:09:57 CEST 2004
* Ivan Voras (2004-09-16 00:10 +0200)
> I need to transform this:
> into this:
> (a left-rotation. Actually, any rotation will do).
> I tried:
> a = a[1:] + a
> which doesn't work because there's no __add__ between a list and
> integer, and:
> a = a[1:].append(a)
> but it doesn't work, since append returns None :( Right now, I'm doing
> it with a temporary variable and it looks ugly - is there an elegant way
> of doing it?
""" shift seq to the left by offset, with the elements shifted off the
beginning inserted back at the end """
return seq[offset:] + seq[:offset]
More information about the Python-list