How can achieve the following: I want to create unique dynamic variables in a for loop self."INSERT DYNAMIC VARIABLE HERE"
list = [box1, box2, box3] for value in list: self."" = Button() You could use exec, but it's highly not recommended see here:
l = [box1, box2, box3] for value in l: exec(f"self.{value} = Button()") I would recommend you to just store it in a dictionary:
l = [box1, box2, box3] self.variables = {} for value in l: self.variables[value] = Button()
listas a name.)self.variables = dict()and keep updating it in the loop like,self.variables[<name>] = value