How to access a variable in a function of a module?

27 views Asked by At

I have a variable in my main code and I have a function in a module made to change such variable. I don't know how to access such variable from an outside function.

# MyModule

def func(x):
  x = x + 2

And I wanto to do:

# Main code
import MyModule
a = 10
MyModule.func(a)
# Expected a = 12
0

There are 0 answers