exponent is a 1D array. This means that
exponent is a scalar, and
exponent[i] is trying to access it as if it were an array.
Did you mean to say:
L = identity(len(l)) for i in xrange(len(l)): L[i][i] = exponent[i]
L = diag(exponent)