I want this to work. [[]] * n

Chris Angelico rosuav at gmail.com
Mon Jun 13 18:51:38 EDT 2011


On Tue, Jun 14, 2011 at 8:37 AM, SherjilOzair <sherjilozair at gmail.com> wrote:
> I want a list which contains n lists, which are all different. I had
> read a page which was about the mutability of lists, and how the *
> operator on lists just does a shallow copy. But I can't find it now.
> Does anyone know of that page ?
>
> Either way, How to get a list of list, with all original lists ?

Bit more verbose, but...
[[] for i in range(n)]
is effective.

ChrisA



More information about the Python-list mailing list