Can someone explain how Python executes this code... | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 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.

26th Jun 2020, 3:54 PM
Jolomi Tosanwumi
2 Respostas
+ 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.
26th Jun 2020, 6:22 PM
Jolomi Tosanwumi
+ 1
Address allocation maybe
26th Jun 2020, 4:22 PM
Itachi
Itachi - avatar