Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #7568
| References | <45f5e602-b196-43b4-97cd-5fa8d4b7058c@h12g2000pro.googlegroups.com> |
|---|---|
| Date | 2011-06-14 08:51 +1000 |
| Subject | Re: I want this to work. [[]] * n |
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.201.1308005500.11593.python-list@python.org> (permalink) |
On Tue, Jun 14, 2011 at 8:37 AM, SherjilOzair <sherjilozair@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
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
I want this to work. [[]] * n SherjilOzair <sherjilozair@gmail.com> - 2011-06-13 15:37 -0700
Re: I want this to work. [[]] * n Chris Angelico <rosuav@gmail.com> - 2011-06-14 08:51 +1000
Re: I want this to work. [[]] * n SherjilOzair <sherjilozair@gmail.com> - 2011-06-14 00:38 -0700
csiph-web