I made a code to simulate an ATM interface, however the 2nd phase seems to have a bug. Step1: Ask to create/choose a bank Account Step2: Pick "create" it goes to def create account: which opens Step3: Enter account number: error(Variable used seems to be undefined?) I dont see the problem, maybe Im blind but i dont see what could be causing the error. Why is my variable: userAnswer always come back undefined.
import tkinter
x=''
bankList = ['100','101','102','103','104','105','106','107','108','109']
def checkAccount():
number = userAnswer.get()
if number == '1':#in bankList:
print("That Account already exist, try another number.")
else:
bankList.append(number)
print("Your new account has been created!")
def createAccount():
window2 = tkinter.Tk()
window2.title("Creating an Account!")
window2.geometry("400x100")
accountLabel = tkinter.Label(window2, text="Please input the 3 digit number for the Account: ")
userAnswer = tkinter.Entry(window2)
accountButton = tkinter.Button(window2, text="Go", command=checkAccount)
accountLabel.pack()
userAnswer.pack()
accountButton.pack()
def selectAccount():
print("nope")
#------------------------- Opening Text Box: Create / Choose Account
window = tkinter.Tk()
window.title("ATM - Inovated Online Banking")
window.geometry("400x100")
label = tkinter.Label(window, text="Thank you for using online Banking Canada. Howe can we help you?")
button = tkinter.Button(window, text="Create Account", command=createAccount)
button2 = tkinter.Button(window, text="Select Account", command=selectAccount)
label.pack()
button.pack()
button2.pack()