1#append to list
2lst = [1, 2, 3]
3something = 4
4lst.append(something)
5#lst is now [1, 2, 3, 4]
1my_list = []
2item1 = "test1"
3my_list.append(item1)
4
5print(my_list)
6# prints the list ["test1"]
1import tkinter as tk
2from tkinter import simpledialog
3from tkinter import messagebox
4import json
5
6ROOT = tk.Tk()
7ROOT.withdraw()
8
9number = 0
10thelist = []
11
12while(number < 3):
13 USER_INP = simpledialog.askstring(title="List",
14 prompt="Add 3 items:")
15 thelist.append(USER_INP + ",")
16 number = number + 1
17
18with open("list.json", 'w') as f:
19 json.dump(thelist, f, indent=2)
20
21with open("list.json", 'r') as f:
22 thelist = json.load(f)
23
24messagebox.showinfo("The List", thelist)
25
26