Python short circuits the logical operators.
if False and Condition2:
#condition2 won't even be checked because the first condition is already false.
if a<p.pop() and b<p.pop():
if all([a < p.pop(), b < p.pop()])
This creates a list, which will be evaluated in its entirety, and then uses
all to confirm that both values are truthy. But this is somewhat obscure and I'd rather suggest you write plain, easy to understand code:
a_within_limit = a < p.pop() b_within_limit = b < p.pop() if a_within_limit and b_within_limit: