Thanks Tom In article <[EMAIL PROTECTED]>, "Dan Perl" <[EMAIL PROTECTED]> wrote:
> A solution that I haven't seen mentioned by other postings in the thread is > to implement the array as a dictionary: > > iMatrix = {} > for index in range(majorlop1): > k = random.choice(listvalues) + 1 > iMatrix[index] = k > > Mind you, a dictionary does not behave *exactly* like an array. For > instance, in your example, you may later do a "del iMatrix[2]" and then you > wouldn't really be able to use iMatrix like an array anymore. But, > depending on your application, a dictionary may be perfectly suitable. > > Hope this helps. > > Dan > > "Thomas Bunce" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > >I am new at Pyton and I am learning from book not classes > > so please forgive my being slow > > > > The below does not work I get an Error of File > > "Matrix[index] = k > > NameError: name 'iMatrix' is not defined" > > > > while index < majorlop1: > > index = index + 1 > > k = random.choice(listvalues) + 1 > > iMatrix[index] = k > > > > The book statement of > > array(typecode, initializer) does not make sence > > to me how it henerates ore relaes to the org name > > for the array. > > > > Thank You > > Tom -- http://mail.python.org/mailman/listinfo/python-list