0 out of 464 challenges solved
Write a function `extract_column(tuples, index)` that takes a list of tuples and an integer `index` as input. The function should return a list containing the elements at the specified `index` from each tuple in the list. #### Example Usage ```python [main.nopy] # Input list of tuples input_tuples = [(1, 2, 3), (4, 5, 6), (7, 8, 9)] # Extract the second column (index 1) result = extract_column(input_tuples, 1) print(result) # Output: [2, 5, 8] # Extract the first column (index 0) result = extract_column(input_tuples, 0) print(result) # Output: [1, 4, 7] ```
def extract_column(tuples, index): """ Extract a specific column from a list of tuples. Args: tuples (list of tuple): The input list of tuples. index (int): The index of the column to extract. Returns: list: A list containing the elements at the specified index from each tuple. """ # Placeholder for the solution pass