Here is a bare-bones example of my code:
def function(): var_a = 1 var_b = 2 var_c = 3 return var_a, var_b, var_c function()
(Apologies for wonky formatting). Basically, the function takes in no arguments and its single job is variable assignment. I need to be able to call on the function for quick assignment and then be able to use those variables in the rest of my code. The problem is that I can’t get those variables out of the function.
So if I use the above code and put a
print(var_a) line after, then it will tell me that var_a is not defined. If I say
values = function() , print (values) then I will get only the values printed in a list, but I won’t be able to access them in the way I want. Is there an easy way to fix this?
Source: Python Questions