Slice assignments can even be used to insert elements without replacing any of the original ones : Assignment « List « Python Tutorial






numbers = [1, 5]
numbers[1:1] = [2, 3, 4]
print numbers








7.3.Assignment
7.3.1.Changing Lists: Item Assignments
7.3.2.Assigning to Slices
7.3.3.Replace the slice with a sequence whose length is different from that of the original
7.3.4.Slice assignments can even be used to insert elements without replacing any of the original ones
7.3.5.You can do the reverse to delete a slice
7.3.6.Print out a date, given year, month, and day as numbers