Abdur-Rahmaan Janhangeer wrote:
> saw this snippet on the internet : why assigning by index propagates it
> all?
It doesn't.
>
a = [[1]] * 7
a
> [[1], [1], [1], [1], [1], [1], [1]]
> >>> a[0][0] = 2
a
> [[2], [2], [2], [2], [2], [2], [2]]
>
> why not
>
> [[1], [2], [2], [2], [
saw this snippet on the internet : why assigning by index propagates it all?
>>> a = [[1]] * 7
>>> a
[[1], [1], [1], [1], [1], [1], [1]]
>>> a[0][0] = 2
>>> a
[[2], [2], [2], [2], [2], [2], [2]]
why not
[[1], [2], [2], [2], [2], [2], [2]]
?
thank you !
--
Abdur-Rahmaan Janhangeer
https://git