## Problem:

I have a text file that contains a matrix of [2][2] 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:
n.append(map(int, line.split()))
f.close()
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[0][i]
print L
```

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.

Thanks.