Prev: ctypes' c_longdouble: underflow error (bug?)
Next: Wholesale Sports Shoes Clear Air Force One AAA++quality(www.cnnshoe.com)
From: Eric J. Van der Velden on 14 Jul 2010 10:54 Hi, I understand this: >>> l=[1,2,3] >>> l[1:2]=[8,9] >>> l [1,8,9,3] But how do you do this with list.insert? Thanks, Eric J.
From: Emile van Sebille on 14 Jul 2010 11:41 On 7/14/2010 7:54 AM Eric J. Van der Velden said... > Hi, > > I understand this: > >>>> l=[1,2,3] >>>> l[1:2]=[8,9] >>>> l > [1,8,9,3] > > But how do you do this with list.insert? > >>> l = [1,2,3,4] >>> l[1:2]="" >>> dummy = [l.insert(1,x) for x in reversed([8,9])] Emile
From: Chris Rebert on 14 Jul 2010 14:10
On Wed, Jul 14, 2010 at 7:54 AM, Eric J. Van der Velden <ericjvandervelden(a)gmail.com> wrote: > Hi, > > I understand this: > >>>> l=[1,2,3] >>>> l[1:2]=[8,9] >>>> l > [1,8,9,3] > > But how do you do this with list.insert? You can't clobber existing items in the list using just .insert(), so the closest you could get is something like: del l[1] l.insert(1,9) l.insert(1,8) Cheers, Chris -- http://blog.rebertia.com |