I have two files:
lib.py
global var
def test():
var = "Hello!"
return
test.py
from lib import *
test()
print(var)
But despite having them in the same folder, when I run test.py, I get the following error:
Traceback (most recent call last):
File "C:\Test\test.py", line 5, in <module>
print(var)
NameError: name 'var' is not defined
How can I access this variable in a function in another file?