0 out of 464 challenges solved
Write a Python function `check_element(lst, element)` that takes in a list `lst` and an element `element`. The function should return `True` if all items in the list are equal to the given element, and `False` otherwise. #### Example Usage ```python [main.nopy] print(check_element([1, 1, 1], 1)) # Output: True print(check_element([1, 2, 1], 1)) # Output: False print(check_element([], 1)) # Output: True ``` #### Constraints - The input list can contain any type of elements. - The function should handle empty lists gracefully.
def check_element(lst, element): """ Check if all elements in the list are equal to the given element. Args: lst (list): The list of elements to check. element (any): The element to compare against. Returns: bool: True if all elements in the list are equal to the given element, False otherwise. """ # Implement the function logic here pass