Software engineering and personal development

Tag: condition

How to Quickly Remove Falsy Values from Lists in Python

One of the most attractive features of Python is its readability and conciseness, allowing developers to write elegant and efficient code. In this article, we will explore a Python method called “Compact” that helps remove falsy values from a list using filter().

The Compact method is a simple yet powerful Python function that removes falsy values (False, None, 0, and “”) from a list. It does this by utilizing the filter() function, which returns an iterator that includes only the elements of the list that satisfy a specific condition.

Continue reading

How to Quickly Check Whether at Least One Condition is Met in Python

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().

Continue reading

© 2024 Fatos Morina

Theme by Anders NorenUp ↑