So my script is working for pulling up the menu but when I pick and option it does not catch the variable outside the main method. I know I just may be doing something small wrong or not can anyone see what my issue is. Much appreciated in advance.
## Text Menu Dynamic test
##version 1
## Created By DragonShadow
## Code produce in Notpad++ For python v3.4.4
import os
import subprocess
import time
import pathlib
## Directory Enumerator
fileFolderLocationFilter = os.listdir('C:\\Users\\myFiles\\Documents\\_Scripts\\MyScripts\\')
selectedFile=""
## Menu defined setting veriables
def My_menu():
files = fileFolderLocationFilter
counter = 1
print (20 * "=" , "Enoc Quick Menu" , 20 * "=")
enumFiles = list(enumerate(files))
for counter, value in enumFiles:
str = repr(counter) + ") " + repr(value);
print(str)
str = repr(counter+1) + ") Exit";
print(str)
print (47 * "_")
str = "Enter your choice [1 - " + repr((counter+1)) + "]:"
choice = int(input("Please Enter a Selection: "))
selectedFiles = enumFiles[choice]
return(selectedFiles[1])
if choice > counter :
choice = -1
else:
selectedFiles = enumFiles[choice]
print(selectedFiles[1])
selectedFile = selectedFiles[1]
return choice
##initiating loop
loop = True
while loop:
choice = My_menu()
print (choice)
print ("---" +str(selectedFile))