I am trying to make it so when a value is not equals to another value, then it will draw a rectangle. Here is my code.
import tkinter
def a():
c1 = 1
c2 = 2
root = tkinter.Tk()
canvas = tkinter.Canvas(root, width=800, height=600)
def b():
if c1 != c2:
print ("test")
canvas.create_rectangle(100, 100, 500, 500, fill='blue')
root.after(10, b)
root.after(10, b)
a()
As you can see, in function b
, if the variable c1
does not equal to c2
(or vice versa) then it should print
"test". However it is not printing, nor is it even running the draw rectangle code.
However, when I place another dummy print
statement before the if
statement, it will print that.
Therefore I can tell that my Not Equals to operand is not working, can anyone see what is wrong with my code?