Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #9305

Re: Python bug? Indexing to matrices

References <394aae4f-92ac-406e-bd44-2d2bd3debd91@l1g2000yql.googlegroups.com>
Date 2011-07-11 22:44 -0700
Subject Re: Python bug? Indexing to matrices
From Chris Rebert <clp2@rebertia.com>
Newsgroups comp.lang.python
Message-ID <mailman.935.1310449448.1164.python-list@python.org> (permalink)

Show all headers | View raw


On Mon, Jul 11, 2011 at 10:39 PM, David <davidbtdt@gmail.com> wrote:
> Should the following line work for defining a matrix with zeros?
>
> c= [[0]*col]*row
>
> where "col" is the number of columns in the matrix and "row" is of
> course the number of rows.

Nope. See the FAQ:
http://docs.python.org/faq/programming.html#how-do-i-create-a-multidimensional-list

Cheers,
Chris

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Python bug? Indexing to matrices David <davidbtdt@gmail.com> - 2011-07-11 22:39 -0700
  Re: Python bug? Indexing to matrices Chris Rebert <clp2@rebertia.com> - 2011-07-11 22:44 -0700
  Re: Python bug? Indexing to matrices Ben Finney <ben+python@benfinney.id.au> - 2011-07-12 15:59 +1000
  Re: Python bug? Indexing to matrices sturlamolden <sturlamolden@yahoo.no> - 2011-07-12 05:59 -0700
    Re: Python bug? Indexing to matrices sturlamolden <sturlamolden@yahoo.no> - 2011-07-12 06:03 -0700
    Re: Python bug? Indexing to matrices David <davidbtdt@gmail.com> - 2011-07-12 06:23 -0700

csiph-web