I am trying to create a function that will repeat a block of code three times. The code has a for loop to alter the background at 500ms intervals. I want this to be repeated three times.
for x in range(0,3):
window.after(500, lambda: window.configure(bg = "blue"))
window.after(1000, lambda: window.configure(bg = "green"))
window.after(1500, lambda: window.configure(bg = "yellow"))
window.after(2000, lambda: window.configure(bg = "purple"))
window.after(2500, lambda: window.configure(bg = "red"))
window.after(3000, lambda: window.configure(bg = "#a1dbcd"))
print x
In the IDE 'x' is printed out three times but the window background only cycles once.
Can someone please help me either fix this code or find an alternate way to do it. Thanks.