So I have a file from which I import another file, in the main file I need to use a variable that is in another file and is under DEF function and IF condition.
But every time I get that there is no such variable.

Code:

First file:

```
from modules.proxy import *
set_proxy()
browser.get("website.com")

```

Second file:

```
def set_proxy():
   if proxy_type == "type1":
    global browser
    browser = webdriver.Chrome(CHROME_DIR)

```

Result: " **name 'browser' is not defined** "
['https://Stackoverflow.com/questions/73693252', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/17238800/']
you should return the browser variable value in the end of the function like this:

```
return browser

```

now get it main file like this:

```
browser = set_proxy()
browser.get("website.com")

```
You need to give a default value for `browser`.

File 1:

```py
browser: str = ""

def test():
    proxy: bool = True
    if proxy:
        global browser
        browser = "TEST"

```

File 2:

```py
import file1

file1.test()
print(file1.browser)
file1.browser = "TEST2"
print(file1.browser)

```

As expected the output are:

```
TEST
TEST2

```