This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author steven.daprano
Recipients samrajput1143, steven.daprano
Date 2021-02-07.20:50:04
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1612731005.01.0.094347832032.issue43157@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2021-02-07 20:50:05steven.dapranosetrecipients: + steven.daprano, samrajput1143
2021-02-07 20:50:05steven.dapranosetmessageid: <1612731005.01.0.094347832032.issue43157@roundup.psfhosted.org>
2021-02-07 20:50:05steven.dapranolinkissue43157 messages
2021-02-07 20:50:04steven.dapranocreate