How to compare multiple variables to the same value?

You want to test a condition for all the variables:

if all(x >= 2 for x in (A, B, C, D)):
    print(A, B, C, D)

This should be helpful if you're testing a long list of variables with the same condition.


If you needed to check:

if A, B, C, or D >= 2:

Then you want to test a condition for any of the variables:

if any(x >= 2 for x in (A, B, C, D)):
    print(A, B, C, D)

Another idea:

if min(A, B, C, D) >= 2:
    print A, B, C, D