diff --git a/README.md b/README.md index 83b272522..4d86268fd 100644 --- a/README.md +++ b/README.md @@ -800,11 +800,11 @@ min_n([1, 2, 3], 2) # [1,2] Returns `False` if the provided function returns `True` for at least one element in the list, `True` otherwise. -Use `all()` in combination with `map()` and `fn` to check if `fn` returns `False` for all the elements in the list. +Use `all()` and `fn` to check if `fn` returns `False` for all the elements in the list. ```py def none(lst, fn=lambda x: x): - return all(map(lambda x: not fn(x), lst)) + return all(not fn(x) for x in lst) ```
diff --git a/snippet_data/snippetList.json b/snippet_data/snippetList.json index acbafab8c..1b820d3da 100644 --- a/snippet_data/snippetList.json +++ b/snippet_data/snippetList.json @@ -844,7 +844,7 @@ "type": "snippetListing", "title": "none", "attributes": { - "text": "Returns `False` if the provided function returns `True` for at least one element in the list, `True` otherwise.\n\nUse `all()` in combination with `map()` and `fn` to check if `fn` returns `False` for all the elements in the list.\n\n", + "text": "Returns `False` if the provided function returns `True` for at least one element in the list, `True` otherwise.\n\nUse `all()` and `fn` to check if `fn` returns `False` for all the elements in the list.\n\n", "tags": [ "list", "function", @@ -852,7 +852,7 @@ ] }, "meta": { - "hash": "5d0682964ee65801c79ed3f165c5c699d61176928fb5bb59e0b02717293b5253" + "hash": "0dd3614b71e7a0b646a084e991eb6b4b2940492a14e6b8159d5d8a60a5abe04d" } }, { diff --git a/snippet_data/snippets.json b/snippet_data/snippets.json index 8c0c805da..86d9aa1af 100644 --- a/snippet_data/snippets.json +++ b/snippet_data/snippets.json @@ -1115,9 +1115,9 @@ "type": "snippet", "attributes": { "fileName": "none.md", - "text": "Returns `False` if the provided function returns `True` for at least one element in the list, `True` otherwise.\n\nUse `all()` in combination with `map()` and `fn` to check if `fn` returns `False` for all the elements in the list.\n\n", + "text": "Returns `False` if the provided function returns `True` for at least one element in the list, `True` otherwise.\n\nUse `all()` and `fn` to check if `fn` returns `False` for all the elements in the list.\n\n", "codeBlocks": { - "code": "def none(lst, fn=lambda x: x):\n return all(map(lambda x: not fn(x), lst))", + "code": "def none(lst, fn=lambda x: x):\n return all(not fn(x) for x in lst)", "example": "none([0, 1, 2, 0], lambda x: x >= 2 ) # False\nnone([0, 0, 0]) # True" }, "tags": [ @@ -1127,7 +1127,7 @@ ] }, "meta": { - "hash": "5d0682964ee65801c79ed3f165c5c699d61176928fb5bb59e0b02717293b5253" + "hash": "0dd3614b71e7a0b646a084e991eb6b4b2940492a14e6b8159d5d8a60a5abe04d" } }, {