For example:
def test(a)
a = 2
b = 5+a
x = a*2
return x
Is there a way to call the variable 'b' outside of the function?
For example:
def test(a)
a = 2
b = 5+a
x = a*2
return x
Is there a way to call the variable 'b' outside of the function?
b = None
def test(a)
global b
a = 2
b = 5+a
x = a*2
return x
print(b)
Although we will suggest to return b
and then access it, as global variable is a bad idea.
See this,
Why are global variables evil?