inserting into a list

John Salerno johnjsal at
Tue Mar 7 16:18:11 CET 2006

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 

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]

I've tried all kinds of combinations of slicing assignment, but I always 

TypeError: can only assign an iterable

Can someone please embarrass me with the simple answer?  :)

More information about the Python-list mailing list