3

Does this exist in Python? I want to combine an If statement that is very repetitive.

# ORIGINAL IF STATEMENT
if a < 100 and b < 100 and c < 100:
    #pass

# I KNOW THIS IS WRONG, I JUST WANT TO KNOW IF THERE IS A WAY TO MAKE THE IF CONDITION SHORTER
if [a,b,c] < 100:
    #pass

2 Answers 2

10

You can use the built-in all():

if all(item < 100 for item in [a, b, c]):
Sign up to request clarification or add additional context in comments.

Comments

3

You can also use the built-in max():

if max(a, b, c) < 100:

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.