import math class Vector(): vA = [3.183, 7.627] def magnitude(vector): sum = 0 i = 0 while i < len(vector): sum += vector[i] i += 1 return math.sqrt(sum) def unitVector(vector): print( 1 / (magnitude(vA) * vA)) I'm attempting to code some linear algebra and calculate the unit vectors for the vector 'vA' stated above. When I run the code I get NameError: global name 'magnitude' is not defined. I do not understand why I am having an issue with simply calling one function from another.
I'm a beginner with python and I'm assuming I have a misunderstanding about classes and functions, but I have looked through the documentation and cannot find the answer I am looking for.