How to do while loops with multiple conditions How to do while loops with multiple conditions python python

How to do while loops with multiple conditions


Change the ands to ors.


while not condition1 or not condition2 or val == -1:

But there was nothing wrong with your original of using an if inside of a while True.


Have you noticed that in the code you posted, condition2 is never set to False? This way, your loop body is never executed.

Also, note that in Python, not condition is preferred to condition == False; likewise, condition is preferred to condition == True.