Error in Following python program

Pramod pramo4d at gmail.com
Sat Sep 4 14:28:06 EDT 2010


#/usr/bin/python
from numpy import matrix
n=input('Enter matrix range')
fr=open('mat.txt','r')
print ('Enter elements into the matrix\n')
a=matrix([[input()for j in range(n)] for i in range(n)])
for i in range(n):
        for j in range(n):
                print a[i][j]
        print '\n'

When i run the above program the following error is Coming please
Error is
                                           Enter matrix range3
Enter elements into the matrix

1
2
3
4
5
6
7
8
9
[[1 2 3]]
Traceback (most recent call last):
  File "2.py", line 10, in <module>
    print a[i][j]
  File "/usr/lib/python2.6/dist-packages/numpy/core/defmatrix.py",
line 265, in __getitem__
    out = N.ndarray.__getitem__

please resolve my problem  Thanks in advance
~



More information about the Python-list mailing list