[Tutor] rotating a list

lonetwin lonetwin at yahoo.com
Mon Sep 22 06:56:05 EDT 2003


On Monday 22 Sep 2003 1:20 pm, Charlie Clark wrote:
> On 2003-09-21 at 22:58:12 [+0200], Gregor Lingl wrote:
> > >You can also rotate at different positions
> > >using different values of pop()
> >
> > hmm..., how do you mean should this be done?
>
> It will allow you to rotate only parts of lists or back-to-front, not
> necessarily with append(), admittedly.
   How about ...

l.insert(x, l.pop(y))

   ...to rotate within lists :o)

where x, is the index where the rotation will start
and y is the index where it will end.

Peace
Steve 

-- 
The clothes have no emperor.
		-- C.A.R. Hoare, commenting on ADA.



More information about the Tutor mailing list