How do I assign a global variable to a function's return? The only way I seem to be able to get it to work properly is to assign the variable to the function itself. When I run the code, the variable assignment performs the function on that line, which is not what I want. I only want an assignment so I can use the variable later.
def random_function():
x = 3.14
return x
This is what I'd like to happen but does not work:
pi = x
This works but runs the function in the console on that line which is not something I want:
pi = random_function()
print(pi)