I have a text file that contains a matrix of  and I am trying to open it in my python program and store the values as integers in a variable. Further, I tried to add some more operations with those values. For better understanding you may check my sample code snippet below:
import numpy as np
with open('test.txt', 'r') as f:
n = 
for line in f:
a = array(n)
l, v = eig(a)
exponent = array(exp(l))
L = identity(len(l))
for i in xrange(len(l)):
L[i][i] = exponent[i]
I am willing to take the values of
exponent and replace the 1's across the diagonal of the identity matrix using the for-loop but this not happening in my case and I am getting an error
IndexError: invalid index to scalar variable.
What is the solid reason behind it, and how can I fix the error? Please help to get rid of this. I appreciate your concern.