Steven D'Aprano <steve+pyt...@pearwood.info> added the comment:
There is also an FAQ about this: https://docs.python.org/3/faq/programming.html#how-do-i-create-a-multidimensional-list See also: https://docs.python.org/3/faq/programming.html#why-did-changing-list-y-also-change-list-x By the way, for future bug reports, please take the time to make a *minimal* example please: http://www.sscce.org/ https://stackoverflow.com/help/minimal-reproducible-example In this case a minimal example would be: mylist = [[0]]*2 mylist[0][0] = 1 print(mylist) # expect [[1], [0]] but get [[1], [1]] Thank you. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue43157> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com