In a While loop, repeat the if condition after it has become true
Question:
I need a quick help with something actually simple, but which seems kind of hard to me personally.
It’s about the following (I think to post a code isn’t needed, but it’s more about the structure):
while <condition 1> :
Action
if (which is IN the while loop) <condition 2> :
Action
Now, in my scenario if condition 1 is true, it keeps repeating the while loop (or rather the Action of condition 1), which is fine and what I’m looking for.
But, however, if the if-condition becomes true, it runs the Action of the if statement (condition 2 became true) only once.
What I’m looking for, is that it should repeat the while-statement from the beginning (so it can repeat the if condition if it should become true again).
Answers:
Okay what you want to achieve can be done by such structure
while True:
#actions
if True:
while True:
pass # when condition is false it will stop
#actions
Just implement your conditions to ‘True’ and you should be fine. but for more accurate answers that would be fine to see your code sample.
I need a quick help with something actually simple, but which seems kind of hard to me personally.
It’s about the following (I think to post a code isn’t needed, but it’s more about the structure):
while <condition 1> :
Action
if (which is IN the while loop) <condition 2> :
Action
Now, in my scenario if condition 1 is true, it keeps repeating the while loop (or rather the Action of condition 1), which is fine and what I’m looking for.
But, however, if the if-condition becomes true, it runs the Action of the if statement (condition 2 became true) only once.
What I’m looking for, is that it should repeat the while-statement from the beginning (so it can repeat the if condition if it should become true again).
Okay what you want to achieve can be done by such structure
while True:
#actions
if True:
while True:
pass # when condition is false it will stop
#actions
Just implement your conditions to ‘True’ and you should be fine. but for more accurate answers that would be fine to see your code sample.