+ 1
Can someone explain how Python executes this code...
Input: a = [[1, 2]]*4 a[1][1] = 5 print(a) Output: [[1, 5], [1, 5], [1, 5] [1, 5]] I was expecting [[1, 2], [1, 5], [1, 2] [1, 2]] as output.
3 Respuestas
+ 2
Great resource 𝐊𝐢𝐢𝐛𝐨 𝐆𝐡𝐚𝐲𝐚𝐥. It cleared the air on variables, naming, references and addresses. Although it didn't explicitly answer my question, but it has demystified the mystery of what goes on underneath the hood in Python.
+ 1
Address allocation maybe