X = [[4,3,9],
          [1,2,0],
          [5,1,4]]
      Y = [[2,7,0],
          [1,2,4],
          [4,5,1]]
      result = [[0,0,0],
              [0,0,0],
              [0,0,0]]
      # iterate through rows
      for i in range(len(X)):  
      # iterate through columns
          for j in range(len(X[0])):
              result[i][j] = X[i][j] + Y[i][j]
      for r in result:
          print(r)
      

      Python language logoAdd Matrices

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.