Numpy.eye() in Python 3
I'm using numpy.eye(N, M, dtype=int)
to print a matrix whose diagonal elements are 1 and rest of the elements are 0. Code:
import numpy
import sys
line = sys.stdin.readline()
N, M = map(int, line.split())
print numpy.eye(N, M, dtype=int)
The above runs successfully in Python 2. But in python 3 I get the following error:
File "solution.py", line 7
print numpy.eye( N , M , dtype =int )
^
SyntaxError: invalid syntax
Is there an alternate package other than numpy in Python 3 through which I can accomplish this? Has the eye
function become obsolete with Python 3?
Topic programming python data-mining
Category Data Science