New submission from John Bachman <jbach...@umass.edu>:
Tested on Python3.6 on Ubuntu 18.04 The following code snippet produces the wrong results. Snippet: M = [[[0] * 2] * 2] * 2 M[0][0][0] = 1 print(M[0][0][0]) # Should be one print(M[1][0][0]) # Should still be zero My output: 1 1 For some reason when you assign to any list inside the 3D matrix, all lists in the array are changed, 2D Matrix works but 3D modifies every 2D matrix. ---------- components: Interpreter Core messages: 338963 nosy: John Bachman priority: normal severity: normal status: open title: 3D Array Assignment to all 2D sub-arrays type: behavior versions: Python 3.6 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue36450> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com