Have extra while loop conditions ... based on a condition?

Viewed 151

The variable a can take any number of values. The value of a is the amount of extra pre-defined conditions to have for the while loop.

This can be done with multiple elif statements but is there a cleaner way of doing this?

if a == 0:
    while condition_1:
        ...
elif a == 1:
    while condition_1 or condition_2:
        ...
elif a == 2:
    while condition_1 or condition_2 or condition_3:
        ...
3 Answers
Related