[Tutor] matrix q?
Evripides Loizides
loizie@hotmail.com
Sat Jun 7 00:37:01 2003
<html><div style='background-color:'><DIV>
<P>i want to add the row of a square matrix. </P>
<P>the code i have is :</P>
<P>myMatrix = [2,7,6], [9,5,1], [4,3,8]</P>
<P>def sumRow(aMatrix, index):<BR> sum = 0<BR> for item in aMatrix[index]:<BR> sum = sum + item<BR> print aMatrix[index]<BR> return sum<BR> <BR>#print sumRow(myMatrix,len(myMatrix)-1)<BR>print sumRow(myMatrix,0) <BR>#print sumRow(myMatrix,1)</P>
<P> </P>
<P>Changing from 0 to 1 and len(myMatrix)-1 i can get the sum of the row each time but i want to put the in a loop so i can get the sum of all row indevidual the same time. </P>
<P>I am looking forward for some good ideas</P>
<P>thanks<BR><BR></P></DIV></div><br clear=all><hr>Protect your PC - <a href="http://g.msn.com/8HMJENUS/2755??PS=">Click here</a> for McAfee.com VirusScan Online </html>