0 out of 464 challenges solved
Write a Python function `union_elements` that takes two tuples as input and returns a new tuple containing the union of the elements from both tuples, sorted in ascending order. #### Function Signature ```python [main.nopy] def union_elements(tuple1: tuple, tuple2: tuple) -> tuple: pass ``` #### Input - `tuple1` (tuple): A tuple of integers. - `tuple2` (tuple): Another tuple of integers. #### Output - Returns a tuple containing the sorted union of elements from `tuple1` and `tuple2`. #### Example Usage ```python [main.nopy] union_elements((3, 4, 5, 6), (5, 7, 4, 10)) # Output: (3, 4, 5, 6, 7, 10) union_elements((1, 2, 3, 4), (3, 4, 5, 6)) # Output: (1, 2, 3, 4, 5, 6) union_elements((11, 12, 13, 14), (13, 15, 16, 17)) # Output: (11, 12, 13, 14, 15, 16, 17) ```
def union_elements(tuple1: tuple, tuple2: tuple) -> tuple: """ Returns a tuple containing the sorted union of elements from tuple1 and tuple2. Args: tuple1 (tuple): First input tuple. tuple2 (tuple): Second input tuple. Returns: tuple: A tuple containing the sorted union of elements. """ # Combine the tuples, remove duplicates, and sort the result pass