title: User defined input for matrix calculation program in Python
body: <p>I have written up this "hard-coded" version of my end goal. As you can see, I have a specific value for n as well as pre-defined matrices X and Y. The program currently performs the calculations just fine but what I'm having trouble with is modifying it to accept user defined input for n, X, and Y and accurately perform the calculations based on what the user enters. I'm still getting used to Python and user input so any help with coding this would be greatly appreciated! I should also note that I'm trying to do this without NumPy for learning purposes. Thanks!</p>
  
  <pre><code># Program to add two matrices
  # using nested loop
  
  n = 3
  
  X = [[12,7,3],
      [4 ,5,6],
      [7 ,8,9]]
  
  Y = [[5,8,1],
      [6,7,3],
      [4,5,9]]
  
  result = [[0,0,0],
           [0,0,0],
           [0,0,0]]
  
  # adds the matrices
  # 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)
  
  
  # subtracts the matrices
  for i in range(len(X)):
     for j in range(len(X[0])):
         result[i][j] = X[i][j] - Y[i][j]
  
  for r in result:
     print(r)
  
  # multiplies the matrices
  for i in range(len(X)):
     # iterate through columns
     for j in range(len(X[0])):
         result[i][j] = sum((X[i][v]*Y[v][j] for v in range(n)))
  
  for r in result:
     print(r)
  </code></pre>