[HELP] Nested conditional? double condition followed by another condition. - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: [HELP] Nested conditional? double condition followed by another condition. (/thread-27257.html) |
RE: [HELP] Nested conditional? double condition followed by another condition. - BitPythoner - May-31-2020 After entering what you have on line 3, enter the following code: and button1_pressed and button2_pressed RE: [HELP] Nested conditional? double condition followed by another condition. - Yoriz - May-31-2020 Try the following do_some_first = False while True: do_some = button1_pressed() and button2_pressed() do_some2 = button3_pressed() if do_some and not do_some2: do_some_first = True elif not do_some: do_some_first = False if not do_some_first: do_some2 = False if do_some: print('do some') if do_some2: print('do some2') RE: [HELP] Nested conditional? double condition followed by another condition. - penahuse - May-31-2020 (May-31-2020, 09:44 PM)Yoriz Wrote: Try the following it seems that when button3 is pressed do_some and do_some2 are true at same time, than the result is:
RE: [HELP] Nested conditional? double condition followed by another condition. - DreamingInsanity - Jun-01-2020 Difinitely not the best way of doing it, but, like always, this should work: isMPressed = False while True: while button1_pressed() and button2_pressed(): print("do some") while button3_pressed() and not isMPressed: # Only if it is pressed after button1 and button2 are pressed isMPressed = False print("do some2") if button2_pressed() == 0: break # this only breaks the inner while loop isMPressed = True if button3_pressed() else False isMPressed = True if button3_pressed() else False RE: [HELP] Nested conditional? double condition followed by another condition. - penahuse - Jun-01-2020 (Jun-01-2020, 08:02 AM)DreamingInsanity Wrote: Difinitely not the best way of doing it, but, like always, this should work: works like a charm! Thank you again!! RE: [HELP] Nested conditional? double condition followed by another condition. - penahuse - Jun-01-2020 Im wondering a scenario a lit bit more complex... is there a way to keep almost the same result, but instead of buttom1 + buttom3 + buttom2 (in this order) resulting "do some",a way to it results "do some2"? |