1import numpy as np
2
3# X is the matrix to invert
4X_inverted = numpy.linalg.inv(X)
1#You can either use the included inv fucntion
2M_inverse = numpy.linalg.inv(M)
3
4#Or use the exponent notation, which is also understood by numpy
5M_inverse = M**(-1)