What is the output of the following code ?
>>> s1 = [34, 56, 71] >>> s2 = s1 >>> s2[2] = 21 >>> s1
[34, 56, 71]
[34, 56, 21]
Error
None of the above
In s2 = s1 , both s1 and s2 shared the reference and refers to the same location in the memory.
When we change s2 in place elements s2[2] = 21, it also changes s1.
Comment here: