дамба пытается создать проект телефонной книги, используя python и Tkinter. Мне нужно добавить номера телефонов в мою телефонную книгу, и я написал код для этого, но python выдает ошибку.
from tkinter import*
#defining the submit button
def submit():
new = entry2.get()
new2 = entry3.get()
my_dict.update({new:new2})
#definig the add button
def add():
top = Toplevel(root)
top.configure(background="black")
top.geometry("400x400")
top.title("Add new member")
label6 =Label(top,text="Welcome",bg="black",fg="orange")
label6.place(x=135,y=13)
global entry2
entry2 = Entry(top,width=23)
entry2.place(x=102,y=78)
label7 = Label(top,text="Name",bg="black",fg="orange")
label7.place(x=48,y=78)
global entry3
entry3 = Entry(top,width = 23)
entry3.place(x=108,y=127)
label8 = Label(top,text="phone number",bg ="black",fg="orange")
label8.place(x=0,y=129)
button3 = Button(top,text="Submit",command = submit)
button3.place(x=185,y=200)
#defining the chek button
def check():
global my_dict
my_dict = {"john":'7598769587'}
if entry.get() in my_dict:
label4 = Label(root,text=my_dict[entry.get()],bg="black",fg="orange").place(x=178,y=167)
label5 = Label(root,text = entry.get()+" is :",bg ="black",fg = "orange").place(x=120,y=167)
#creating the main window
root = Tk()
root.title("vole phone book")
root.geometry("400x400")
root.configure(background="black")
label = Label(root,text="phone book",bg="black",fg="orange",width=13).place(x=133,y=23)
label2 = Label(root,text="Enter here.",bg = "black",fg="orange").place(x=2,y=89)
entry = Entry(root,width = 27)
entry.place(x=89,y=90)
button =Button(root,text="Check",bg="yellow",fg="red",command=check).place(x=190,y=129)
button2=Button(root,text="Add",width=23,command = add).place(x=120,y=300)
root.mainloop()
Это мой код, и когда я выполняю этот код
my_dict.update({new:new2})
NameError: name 'my_dict' is not defined
python, появляется указанная выше ошибка. Что делать?