title: Python reading matrix from file
body: <p>This is for my IT class, i am trying to find the sum of each row. Its a magic square program. when i run this it says int object not iterable.  Also the teacher wants the header of the function like this def rowSum(matrix, rowNum) but i dont understand why rowNum would be needed. The function should be able to calculate the sum of each row of any size matrix. Also i cant use numpy and enumarate as we have not talked about it in class yet.</p>
  
  <p>Matrix txt file:</p>
  
  <pre><code>1 4
  3 2 
  </code></pre>
  
  <p>Here is code</p>
  
  <pre><code>def main():
      filNam = "matrix1.txt"
      matrix = (readMatrix(filNam))
      print(eachNumPresent(matrix))
      print(rowSum(matrix))
  
  def readMatrix(filNam):
      matrixFile = open(filNam, "r")
      line = matrixFile.readline()
      for line in matrixFile:
          line = line.split()
      return line
      matrixFile.close()
  
  def eachNumPresent(matrix):
      if len(matrix) % 2 == 0:
          return True
      else:
          print("Not enough numbers")
  
  def rowSum(matrix, rowNum):
      for line in matrix:
          return(sum(int(line)))
  
  main()
  </code></pre>