[EMAIL PROTECTED] wrote:
x = [[0] * ncols for i in nrows]
That gives an error... small typo corrected:
y = [[0] * ncols for i in range(nrows)]
Greetings,
--
"The ability of the OSS process to collect and harness
the collective IQ of thousands of individuals across
the Internet is simply ama
En Tue, 11 Nov 2008 23:09:25 -0200, <[EMAIL PROTECTED]> escribió:
On Nov 11, 7:48 pm, [EMAIL PROTECTED] wrote:
To create a 2D list, that is a list of lists:
x = [[0] * ncols for i in nrows]
Many thanks, I don't think I would ever 'discovered' this.
Try reading the FAQ:
http://www.python.
[EMAIL PROTECTED] wrote:
On Nov 11, 7:48 pm, [EMAIL PROTECTED] wrote:
gc_ott:
How do I change the value of any element to produce (say)
[[99,0,0],[0,0,0],[0,0,0]] ?
gordc
To create a 2D list, that is a list of lists:
x = [[0] * ncols for i in nrows]
(Don't do what you were doing, because you
On Nov 11, 7:48 pm, [EMAIL PROTECTED] wrote:
> gc_ott:
>
> > How do I change the value of any element to produce (say)
> > [[99,0,0],[0,0,0],[0,0,0]] ?
>
> > gordc
>
> To create a 2D list, that is a list of lists:
> x = [[0] * ncols for i in nrows]
> (Don't do what you were doing, because you end w
gc_ott:
> How do I change the value of any element to produce (say)
> [[99,0,0],[0,0,0],[0,0,0]] ?
>
> gordc
To create a 2D list, that is a list of lists:
x = [[0] * ncols for i in nrows]
(Don't do what you were doing, because you end with many references to
the same list, and that will give you t
On Tue, Nov 11, 2008 at 7:32 PM, <[EMAIL PROTECTED]> wrote:
> I want to construct a 2-dimensional array from a List but I cannot
> find a simple way of changing any element. For example, construct a
> 3x3 array like this:-
> >>> x=[0,0,0]
> x=[x]*3
> this produces [[0,0,0],[0,0,0],[0,0,0]. S
I want to construct a 2-dimensional array from a List but I cannot
find a simple way of changing any element. For example, construct a
3x3 array like this:-
>>> x=[0,0,0]
x=[x]*3
this produces [[0,0,0],[0,0,0],[0,0,0]. So far so good.
How do I change the value of any element to produce (say)