Similar to the case of using any(), we can also use a method that allows us to check whether all conditions are met. This can also greatly reduce the complexity of the code since you do not need to use multiple and checks.
Let us see this with an example.
Let us assume that we have the following conditions where we are checking whether we have more than 50 points in each school course:
Now passing all of them means that each condition should be met. To help us with that, we can simply use all(), as can be seen in the following snippet:
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().
I am an experienced and passionate Senior Software Engineer with a demonstrated history of working in the full life cycle of software development with enormous curiosity for data science, machine learning, algorithms, data structures, and solving challenging problems. I am an open-source enthusiast at https://github.com/fatosmorina and also a writer.
I am open for new opportunities.