2 ms·
> Assigning to a list slice will replace that range in the original sequence with what's referenced even if their lengths are different. Not only that, but you
by carapace 6y ago
> Assigning to a list slice will replace that range in the original sequence with what's referenced even if their lengths are different.
Not only that, but you can assign to a slice with a stride:
In [1]: r = list(range(10))
In [2]: r
Out[2]: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
In [3]: r[1::3] = 10, 20, 30
In [4]: r
Out[4]: [0, 10, 2, 3, 20, 5, 6, 30, 8, 9]