How to pack widgets inside a frame in Tkinter one above the another when looping?

I am looping through the main frame, and adding new frames with text inside it but it gets added to the bottom of the previous frame by default.

f3=Frame(wf).pack()

nf=Frame(f3, border=2, relief=SOLID)
nf.pack(pady=5, padx=80)
for i in l:
    text=Label(nf, text=i, pady=5)
    text.pack()

Here, I want the nf (new frames) to get added above the previous nf.

Link to whole code:https://github.com/Tashyab/python-workshop/blob/master/Tkinter/newspaper.py


You can use before option of .pack().

Below is an example:

f3 = Frame(wf)
f3.pack()

nf = None

def new_frame():
    global nf

    f = Frame(f3, bd=2, relief=SOLID)
    f.pack(before=nf, pady=5, padx=80) # pack before previous frame
    nf = f

    for i in l:
        Label(nf, text=i, pady=5).pack()