From 3e901677d7e61847d499b76d8d7efdf988b727ed Mon Sep 17 00:00:00 2001 From: Angelos Chalaris Date: Sun, 22 Sep 2019 15:29:50 +0300 Subject: [PATCH] Update none.md --- snippets/none.md | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/snippets/none.md b/snippets/none.md index b9644e197..b12512d2b 100644 --- a/snippets/none.md +++ b/snippets/none.md @@ -5,15 +5,11 @@ tags: list,function,intermediate Returns `False` if the provided function returns `True` for at least one element in the list, `True` otherwise. -Iterate over the elements of the list to test if every element in the list returns `False` based on `fn`. -Omit the seconds argument, `fn`, to check if all elements are `False`. +Use `all()` in combination with `map()` and `fn` to check if `fn` returns `False` for all the elements in the list. ```py -def none(lst, fn=lambda x: not not x): - for el in lst: - if fn(el): - return False - return True +def none(lst, fn=lambda x: x): + return all(map(lambda x: not fn(x), lst)) ``` ```py