Skip to content
Advertisement

How to get items that are true for ANY() method in Python

Say:

JavaScript

How to get the signs it found true in the iteration? Here’s a way

JavaScript

Is there a better one liner way of doing it? (Without the for loop maybe)

Advertisement

Answer

With the few modifications to the any expression, you can get whether each of the signs is in the expression, which signs are in the expression, or just the first such sign:

JavaScript

(In the last one, None is the default in case no such element exists.)

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement