Mutable lists: updating slices

Slices can be updated using the bracket operator:

aList = [1, 2, 3, 4, 5, 6]

aList[1:4]=[9]    # replace elements with one element with value 9
print aList

aList[0:0]=[0,0]  # insert two elements with value 0
print aList

aList[1:3]=[]     # delete two elements
print aList

prints:

[1, 9, 5, 6]
[0, 0, 1, 9, 5, 6]
[0, 9, 5, 6]