I think I'm just unaware of some basic syntax here.
The following code gives an error "global name 'adder' is not defined".
def math(a, b):
adder = a + b
return adder
def usesmath(x, y):
math(6, 4)
subtractor = adder - (x + y)
print subtractor
usesmath(3, 2)
Clearly, this doesn't work because the variable 'adder' does not exist within usesmath(); how can I make the variable be recognised?
adder = math(6, 4). This is not basic syntax, it's basic semantics: a function returns a value without a name.subtractor = math(6, 4) - (x + y)