Python doc says that slicing a list returns a new list.
Now if a "new" list is being returned I've the following doubts related to "Assignment to slices"
a = [1, 2, 3]
a[0:2] = [4, 5]
[4, 5, 3]
You are confusing two distinct operation that use very similar syntax:
b = a[0:2]
This makes a copy of the slice of
a and assigns it to
2) slice assignment:
a[0:2] = b
This replaces the slice of
a with the contents of
Although the syntax is similar (I imagine by design!), these are two different operations.