May-31-2020, 04:22 PM
In your function, you get the state of the button press. It can be an integer between 1 and 0 (pressed or not pressed).
When you return it, to get a True or False output you check if it is less than 0.
When the key isn't pressed, button_state is going to be 0:
0 < 0 = True.
Meaning when the button isn't pressed the while loop can still run. Surely you would want something like this:
Am I missing something here?
When you return it, to get a True or False output you check if it is less than 0.
When the key isn't pressed, button_state is going to be 0:
0 < 0 = True.
Meaning when the button isn't pressed the while loop can still run. Surely you would want something like this:
return bool(button1_state)Since bool(0) returns False, and bool(1) returns True.
Am I missing something here?