inserting into a list
johnjsal at NOSPAMgmail.com
Tue Mar 7 17:01:18 CET 2006
Diez B. Roggisch wrote:
>>>> l = [1,2,3]
>>>> l.insert(2, 10)
> [1, 2, 10, 3]
> Embarrasing enough?
Actually, I was trying to figure it out with the slice technique
instead. But yeah, as Christopher's example showed, it's not hard. But I
didn't realize you had to assign a list item to the slice, so I was doing:
L[2:2] = 3
among other things, but they all involved '= 3', not '= '
More information about the Python-list