0 out of 464 challenges solved
Write a Python function `insert_element(lst, element)` that takes in a list `lst` and an element `element`. The function should insert the given `element` before each element in the list `lst` and return the resulting list. #### Example Usage ```python [main.nopy] insert_element(['Red', 'Green', 'Black'], 'c') # Output: ['c', 'Red', 'c', 'Green', 'c', 'Black'] insert_element(['python', 'java'], 'program') # Output: ['program', 'python', 'program', 'java'] insert_element(['happy', 'sad'], 'laugh') # Output: ['laugh', 'happy', 'laugh', 'sad'] ```
def insert_element(lst, element): """ Inserts the given element before each element in the list. Args: lst (list): The original list. element (any): The element to insert before each item in the list. Returns: list: The modified list with the element inserted before each item. """ # Your code here pass