0 out of 464 challenges solved
Write a function `extract_even` that takes a nested tuple of integers and removes all odd numbers from it. The function should preserve the structure of the nested tuple while only retaining even numbers. #### Example Usage ```python [main.nopy] print(extract_even((4, 5, (7, 6, (2, 4)), 6, 8))) # Output: (4, (6, (2, 4)), 6, 8) print(extract_even((5, 6, (8, 7, (4, 8)), 7, 9))) # Output: (6, (8, (4, 8))) print(extract_even((5, 6, (9, 8, (4, 6)), 8, 10))) # Output: (6, (8, (4, 6)), 8, 10) ``` #### Constraints - The input will always be a tuple. - The tuple can contain integers or other nested tuples. - The function should handle arbitrarily nested tuples.
def extract_even(nested_tuple): """ Removes all odd numbers from a nested tuple, preserving the structure. Args: nested_tuple (tuple): A tuple containing integers or other nested tuples. Returns: tuple: A new tuple with only even numbers. """ # Placeholder for the solution pass