# list comprehension question

Dwight Hutto dwightdhutto at gmail.com
Wed Oct 17 04:19:48 CEST 2012

```On Tue, Oct 16, 2012 at 10:13 PM, Dwight Hutto <dwightdhutto at gmail.com> wrote:
> On Tue, Oct 16, 2012 at 9:54 PM, Kevin Anthony
> <kevin.s.anthony at gmail.com> wrote:
>> I've been teaching myself list comprehension, and i've run across something
>> i'm not able to convert.
>>
>> here's the original code for matrix multiplcation
>>
>> retmatrix = Matrix(self.__row,other.__col)
>> for m in range(0,retmatrix.__row):
>>     for n in range(0,retmatrix.__col):
>>         product = 0
>>         for p in range(1,self.__col+1):
>>             product += (self.__matrix[m][p] * other.__matrix[p][n])
>>         retmatrix.__matrix[m][n] = product
>>
>> Here is what i have so far:
>> retmatrix.__matrix = [[ product = product + (self.__matrix[m][p]*
>> other.__matrix[p][n])
>>                  if product else self.__matrix[m][p]* other.__matrix[p][n])
>>                  for p in range(0,self.col)
>>                  for n in range(0,self.col)]
>>                  for m in range(0,self.__row)]
>>
>> But i know that isn't correct, can someone nudge my in the right direction?
>>
>>
>> --
>> Thanks
>> Kevin Anthony
>> www.NoSideRacing.com
>>
>> Do you use Banshee?
>>
>>
>> --
>> http://mail.python.org/mailman/listinfo/python-list
>>
>
>
> I did this a little while back for something else, but memories get
> jumbled up in these molecules of data I have floating around in my
> mind, but maybe this will put you on the right track.
>
>
> --