Once any()
encounters an item that results in true
from the lambda
expression, any()
is done. It no longer needs to examine the remaining
items in the list. So, it returns true
at that point.
This is one of the reasons why side effects are something to avoid when using functional programming. You do not know whether your side effect (e.g., printing the item) will be applied to every item or not.
You can learn more about this in:
Tags: