For example I have a button and I would like to use it to turn something on and off with the same button.
So I thougt, I would use some wariable which woild keep track of the state, but I can't seem to make it work.
I would need to initialize X to value 0, but that initialization should happen only once when the program starts.
x = 0 -> (this part should happen only when program is started)
if x == 0:
turn switch on
x = 1
else:
turn switch off
x = 0
So I thougt, I would use some wariable which woild keep track of the state, but I can't seem to make it work.
I would need to initialize X to value 0, but that initialization should happen only once when the program starts.
x = 0 -> (this part should happen only when program is started)
if x == 0:
turn switch on
x = 1
else:
turn switch off
x = 0
Comment