The program first asks the user if they'd like to load their own file or use the the file provided by the script.
filename=0
def first(filename):
print('Please Select:')
print('Run Program Now? Press "1"')
start = int(input('Load Your Own List and Run Program? Press "2": '))
if start ==1:
global filename
filename = 'file.txt'
elif start ==2:
import tkinter as tk
from tkinter import filedialog
root = tk.Tk()
root.withdraw()
global filename
filename = tkinter.filedialog.askopenfilename()
else:
print("You didn't enter a valid selection!")
first(filename)
main()
I'm using another function which should call the correct file based on the user input.
def guess(real):
WORDLIST = filename
with open(WORDLIST, 'r') as in_file:
Error:
ErrorSyntaxError: name 'filename' is assigned to before global declaration
This all worked earlier when I had the user input and elif statements within
def guess(real):
Although I wanted to call it separately and that's why I have the user input in it's own function.