inserting into a list

Christoph Haas email at christoph-haas.de
Tue Mar 7 10:32:01 EST 2006


On Tuesday 07 March 2006 16:18, John Salerno wrote:
> Let me apologize in advance for what I'm sure is an achingly simple
> question, but I just can't find the answer in either of my Python books.
> I've tried a few tests with the interactive prompt, but they don't work
> either.
>
> All I'm trying to do is insert an item into a list, like so:
>
> L = [1, 2, 4]
>
> and I want to insert the integer 3 into the position L[2], so that the
> list reads [1, 2, 3, 4]

Either

L[2:2]=[3]

or

L.insert(2,3)

Kindly
 Christoph
-- 
~
~
".signature" [Modified] 1 line --100%--                1,48         All



More information about the Python-list mailing list