'Function execution incompatible with Tkinter Button (Not a lambda thing, at least I think)

Yeah, so as the question states the function doesn't work with buttons, here's the code: Just for context the loop's prepose is to display each element in the 2d array stud, which stores data like this [[name, (p, class description), (a, class description][name2...] It's an attendance thing. Anyway the problem is specifically with the functions Yeas, Neas and but_yes, but_no along with the code following that.

def work():
        num = int(len(stud[0]))
        z = ent.get()
        if num <= 25:
            k = alph[num]
        else:
            m = int(num / 25)
            k = str(alph[m - 1]) + str(alph[(num - 25 * m) - 1 * m])
        for i in range(0, len(stud)):
            Lable_l = Label(root, text=("Is " + stud[i][0] + " present?"))
            Lable_l.grid(row=(9 + i), column=0)

            def Yeas(a):
                stat = str(a)
                f = k + str(i + 2)
                sheet_atten[k + str(1)] = z
                stud[i].append([stat, z])
                sheet_atten[f].value = stat
                print(stud)
            but_yes = Button(root, text="Yes", command=lambda: Yeas('p'))
            but_yes.grid(row=(9 + i), column=1)
            but_no = Button(root, text="No", command=lambda: Yeas('a'))
            but_no.grid(row=(9 + i), column=2)

            print(stud)
            workbook_atten.save(filename=nam_atten)

This is only a small excerpt from the rest that i didn't want to bore you with. This is only the latest iteration and ig i just need to rewrite the function around the button. I have tried in ways where it accepts a or p as a parameter where I input it with lambda. I have tried the make the if statement part of the code, so it just executes it when i push the button, no luck. Fir whatever it's worth, I have not been able to solve the problem, but only fix it to a point where it loops to the end of the stud array to execute, meaning i can only change the last element, not what I want. I know it's probably something basic but tkinter makes my head hurt and nothing I try seems to fix it, any help is appreciated.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source