[enter image description here][1]I defined my label widget correctly at the top unsure why it's throwing the error that the lbl is defined in an enclosing scope. Can someone explain where is this enclosing scope and where I've gone wrong?
global lbl
lbl = tk.Label(tab1)
def display_each(value):
ID = value
# TO CHECK IF IT WORKS
print(ID)
if ID == 0:
add = 0
if ID == 1:
add = 5
if ID == 2:
add = 6
if ID == 3:
add = 9
c.execute(f'''
SELECT * FROM Workout
WHERE Program_Routine_ID = {ID}
''')
x = c.fetchall()
for i in range(len(x)):
c.execute(f'''
SELECT ID,Name,Equipment,Difficulty,Muscle FROM Exercise
WHERE Workout_ID = {i+(ID+add)}
''')
y = c.fetchall()
print(f'{x[i][2].upper()} workout.{len(y)} exercises:')
print()
for j in range(len(y)):
if y[j][2] == "None" or y[j][2] == "none":
lbl.config(text = f'{y[j][0]+1} ) {y[j][1]}.\n Requires no equipment. \n It is {y[j][3]} difficulty.\n It works the {y[j][4]} muscles with workout id {i+(ID+add)}')
else:
lbl = tk.Label(tab1, text = f'{y[j][0]+1} ) {y[j][1]}.\n Requires {y[j][2]}. \n It is {y[j][3]} difficulty.\n It works the {y[j][4]} muscles with workout id {i+(ID+add)}')
lbl.pack()
#print(time.time()-time.time())
#display_each()