Hello. i have this problem with a program im coding in python. heres the code:
#! /usr/bin/python
from Tkinter import *
list=[".", ".", ".", ".", ".", ".", ".", ".", "."]
root=Tk()
def p(lol):
list[0]=1
lol["text"] = list[0]
def plade():
###### ROW=0
a1=Button(root, text=list[0], command=p(a1))
a1.grid(row=0)
a2=Button(root, text=list[1], command=p(a2))
a2.grid(row=0, column=1)
a3=Button(root, text=list[2], command=p(a3))
a3.grid(row=0, column=2)
##### ROW=1
plade()
root.mainloop()
and heres the output:
Traceback (most recent call last):
File "./kryds", line 26, in <module>
plade()
File "./kryds", line 13, in plade
a1=Button(root, text=list[0], command=p(a1))
UnboundLocalError: local variable 'a1' referenced before assignment
Could you guys please help me figure this out, and explain the solution?