The problem here is that you're trying to interact with a local variable, so you have to use the keyword "global variable" inside the function before interacting with it. Another problem is the circular imports in Python (check this answer: Circular (or cyclic) imports in Python).
If you do import foo (inside bar.py) and import bar (inside foo.py), it will work fine. By the time anything actually runs, both modules will be fully loaded and will have references to each other.
The problem is when instead you do from foo import abc (inside bar.py) and from bar import xyz (inside foo.py). Because now each module requires the other module to already be imported (so that the name we are importing exists) before it can be imported.