includes()
Checks if a given value is present in a collection.
Implementation
Args: collection: The collection to search in. Can be a dictionary or a list. value: The value to search for. Returns: Whether the value is present in the collection.
Example
includes([1, 2, 3], 2)
Expected output: True
Source Code
def includes(collection: Union[Dict[Any, Any], List[Any]], value: Any) -> bool:
if isinstance(collection, dict):
return value in collection.values()
return value in collection