from tkinter import *
from tkinter import ttk
from tkinter.filedialog import asksaveasfile
root = Tk()
root.geometry('200x150')
Text = ['word','great','text']
def save():
text_file = asksaveasfile(title="Select Location", filetypes=(("Text Files", "*.txt"),))
with open(text_file, 'w') as f:
f.write(Text)
btn = ttk.Button(root, text = 'Save', command = lambda : save())
btn.pack(side = TOP, pady = 20)
mainloop()
TypeError: expected str, bytes or os.PathLike object, not TextIOWrapper
I have a list called Text. I want to print the contents of the list into a text file. What should I do?