0 out of 464 challenges solved
Write a Python function `extract_first_elements` that takes a list of sublists as input and returns a new list containing the first element of each sublist. #### Example Usage ```python [main.nopy] print(extract_first_elements([[1, 2], [3, 4, 5], [6, 7, 8, 9]])) # Output: [1, 3, 6] print(extract_first_elements([[1, 2, 3], [4, 5]])) # Output: [1, 4] print(extract_first_elements([[9, 8, 1], [1, 2]])) # Output: [9, 1] ``` #### Constraints - Each sublist will have at least one element. - The input list will contain at least one sublist.
def extract_first_elements(lst): """ Extract the first element from each sublist in the given list. Args: lst (list of list): A list containing sublists. Returns: list: A list containing the first element of each sublist. """ # Write your code here pass