Newbie: How do I implement an 2 element integer array in Python=?ISO-8859-1?B?hQ==?=.?

Fran=?ISO-8859-1?B?5w==?=ois Granger fgranger at teleprosoft.com
Wed Oct 11 10:41:05 EDT 2000


in article 8s1s48$89a$1 at nnrp1.deja.com, jbranthoover at my-deja.com at
jbranthoover at my-deja.com wrote on 11/10/00 16:06:

> Hello All,
> What is the syntax for creating a 2 element integer array?  I
> have looked at the Array  Module documentation,  but I am afraid that I
> don’t quite understand it.  In Basic I would do something like:
> 
> Dim    MyArray(100,16)
> 
> For i = 0 to 100
> For j = 0 to 16
> MyArray( i,j ) = MyData
> Next j
> Next i

I would say (not tested)

MyArray = []
for i in range(100):
    MyArray.append([])
    for j in range(16):
        MyArray[i].append([])

and then you adress it with
MyArray[i][j] = 10
and
MyInt = MyArray[i][j]


Salutations,
Francois Granger
-- 
fgranger at teleprosoft.com - <http://www.teleprosoft.com>
tel: +33 1 41 88 48 00 - Fax: + 33 1 41 88 04 90




More information about the Python-list mailing list