Im designing a Mastermind game, and so far have come up with a circle that changes color with iterating through a list of colors with the press of a button:
set_up_answer = []
color_iteration1 = itertools.cycle(('blue', 'green', 'orange', 'red','yellow'))
def callback1():
mcircle1 = mycanvas.create_oval(10,620,86,675,outline='#000000',fill=next(color_iteration1))
res1 = mycanvas.itemcget(mcircle1, 'fill')
set_up_answer.append(res1)
B1 = Button(root,text='B1',command =callback1)
Keep in mind this is not complete code***, and what happens is that if i go through the iterate list by pressing the button multiple times, end up with say the circle containing the fill 'orange' and then add it to (set_up_answer) to compare to other circles, what it returns is something like ['blue', 'green', 'orange'], meaning it returns every color in the iterate list before what the actual fill is as well as the actual fill color, how do I limit the value returning the fill to just the specific color of the iterate list it actually is?
set_up_answerto only have one value? Are you using a list as a global so that you can modify it within the function? You could just haveglobal set_up_answerin the function , then you can assign to it. This isn't ideal, but will work.