How can I add code to the following code to clear the entry field once i have entered the data?
<p>I entered this thinking it might work but it doesn't. Not sure if this is correct or I need to change it. It doesn't work so I am guessing it does need changing.</p>

<p>Import from tkinter:</p>

<pre><code>from tkinter import * 
import csv
def delete_entries():
    for field in fields:
        field.delete(0,END)

class App(Frame):
    def __init__(self, master=None):
        Frame.__init__(self, master)
        self.pack()
        self.output()
</code></pre>

<p>Output:</p>

<pre><code>def output(self):
    Heading=StringVar()
    Heading.set("Please enter student name below")
    Label(text='Name:').pack(side=LEFT,padx=5,pady=5)
    self.n = Entry(root, width=10)
    self.n.pack(side=LEFT,padx=5,pady=5)
</code></pre>

<p>Text label:</p>

<pre><code>    Label(text='Grade:').pack(side=LEFT,padx=5,pady=5)
    self.e = Entry(root, width=10)
    self.e.pack(side=LEFT,padx=6,pady=6)

    self.b = Button(root, text='Submit', command=self.writeToFile)
    self.b.pack(side=RIGHT,padx=5,pady=5)

    self.b = Button(root, text='Clear', command=self.writeToFile)
    self.b.pack(side=RIGHT,padx=5,pady=5)
</code></pre>

<p>Write to grade CSV:</p>

<pre><code>def writeToFile(self):
    with open('Grades.csv', 'a') as f:
        w=csv.writer(f, quoting=csv.QUOTE_ALL)
        w.writerow([self.n.get()])
        w.writerow([self.e.get()])

if __name__ == "__main__":
    root=Tk()
    root.title('grade')
    root.geometry('380x280')
    app=App(master=root)
    app.mainloop()
    root.mainloop()

    Delete_button = Button(root, text = 'Clear', command = delete_entries)
    Delete_button.pack()
</code></pre>

<p>you can add this to end of the code that submits the entries</p>

<pre><code>self.n.delete(0, END)
self.e.delete(0, END)
</code></pre>

python tkinter