Creating a matrix?
Ivan Voras
iv at an.voras.fer
Fri Apr 2 10:41:38 EST 2004
Peter Maas wrote:
> Ivan Voras wrote:
>
>> Is there a nice(r) way of creating a list of uniform values? I'm
>> currently using: list('0'*N), which makes a string and then chops it
>> up into a list. I need it to create a NxN matrix:
>>
> > matrix = [list('0'*N) for i in range(N)]
>
> matrix = [['0']*N]*N
I can't believe I didn't try that one :)
(hmm, actually, I think I tried it but the results were bad for some
reason... oh well, thank you :) )
More information about the Python-list
mailing list