In many cases, we may have multiple conditions that we want to check, and going through each one of them can be a clutter.
First and foremost, we should keep in mind that we write code for other humans to read it. These are our colleagues that work with us, or people who use our open source projects.
As such, checking whether at least one condition is met can be done using a very quick way by using the method any().
Let us say that we have a few conditions and we save all of them in a single list:
math_points = 51 biology_points = 78 physics_points = 56 history_points = 72 my_conditions = [math_points > 50, biology_points > 50, physics_points > 50, history_points > 50]
Now checking whether at least one such condition is true can be done pretty quickly in the following way:
if any(my_conditions):
print("Congratulations! You have passed all of the exams.")
else:
print("I am sorry, but it seems that you have to repeat at least one exam.")
# Congratulations! You have passed all of the exams.
As you can see, instead of using multiple if and or checks, we are simplifying this into such shorter conditions which are prettier to see and easier to understand.
I hope you find this useful.