I want to get a directory with a function and use the obtained path in another function. For example, I'm just giving a simple code sample.
def browse_folder():
input_folder = input("enter your directory: ")
def action():
print(input_folder)
The thing is: until I call the first function, you can't use the variable from the first function in the second function.
But I can't call the first function first because it's graphical (tkinter) and the user needs to click a button first and specify the path, and then call the function inside the button.
Thanks in advance for your guidance.
I have used 'return' and 'global', but they haven't been effective.
browse_folder,input_folderdoesn't exist. you simply must callbrowse_folderif you need access toinput_folder.returnto return the value obtained inbrowse_folder()and store it in the calling code. Then pass that stored value as an argument toaction(). You say you used triedreturnbut it "wasn't effective". Perhaps you could post the code you tried for that as well, since you were on the right track.input_foldera global variable. Am I missing something?