In a python function, I have defined two variables as letters.
def Vandermonde(x, d):
x_0=-1
a = np.arange(d)
I am getting the error that "d"is not defined in a = np.arange(d). I suspect, but could be wrong, that this is because d is classified as a string not an integer.
I was expecting this to not matter in the code of the function where d is a variable. I know the code works (the rest of the code not shown does work on its own where d is defined as an integer before hand. How do I get the error message to not appear when defining this as a function?
CodePudding user response:
Indentation! Python functions (and their respective scopes) are defined via indentations.
def Vandermonde(x, d):
x_0=-1
a = np.arange(d) # Note the indentation here
should fix the problem...