diff --git a/guide/english/python/any-iterable/index.md b/guide/english/python/any-iterable/index.md index 5855801b95..87160bddcf 100644 --- a/guide/english/python/any-iterable/index.md +++ b/guide/english/python/any-iterable/index.md @@ -1,8 +1,12 @@ --- title: Python Any Iterable --- -`any()` is a built-in function in Python 3 (and Python 2 since version 2.5), to check if any of the items of an _iterable_ is `True`. It takes one argument, `iterable`. +`any()` is a built-in function in Python 3 (and Python 2 since version 2.5), to check if any of the items of an _iterable_ is `True`. It takes one argument, `iterable`. This table below is helpful in understanding `all` and `any` iterable. +
+
+
+
## Argument
### iterable
@@ -11,7 +15,7 @@ The `iterable` argument is the collection whose entries are to be checked. It ca
## Return Value
-The return value is a Boolean. If and only if **all** entries of iterable are `False`, or the `iterable` is empty; it returns `False`. This function essentially performs a Boolean `OR` operation over all elements.
+The return value is a Boolean. It returns 'False' if and only if **all** entries of iterable are `False`, or the `iterable` is empty. This function essentially performs a Boolean `OR` operation over all elements.
If even one of them is `True`, it returns `True`.
@@ -22,6 +26,8 @@ The `any()` operation is equivalent to (internally, may not be implemented exact
if element:
return True
return False
+
+It stops the execution as soon as the result is known.
## Code Sample
@@ -33,7 +39,13 @@ The `any()` operation is equivalent to (internally, may not be implemented exact
print(any([6, 7, None])) #=> True
print(any([0, 6, 7])) #=> True
print(any([9, 8, [1, 2]])) #=> True
+ print(any([None, []])) #=> False
+ print(any([9, False, [1, 2]])) #=> True
-Run Code
+🚀 Run Code
Official Docs
+
+### Sources
+1. Any & All in Python, Accessed: October 22, 2018
+2. Image, Accessed: October 22, 2018