0 out of 464 challenges solved
Write a function `add_dict_to_tuple(test_tup, test_dict)` that takes a tuple `test_tup` and a dictionary `test_dict` as inputs. The function should return a new tuple that includes all elements of `test_tup` followed by `test_dict` as the last element. #### Example Usage: ```python [main.nopy] result = add_dict_to_tuple((4, 5, 6), {"MSAM": 1, "is": 2, "best": 3}) print(result) # Output: (4, 5, 6, {'MSAM': 1, 'is': 2, 'best': 3}) result = add_dict_to_tuple((1, 2, 3), {"UTS": 2, "is": 3, "Worst": 4}) print(result) # Output: (1, 2, 3, {'UTS': 2, 'is': 3, 'Worst': 4}) ``` #### Constraints: - The input tuple and dictionary will always be valid. - The function should not modify the original tuple. - The function should return a new tuple.
def add_dict_to_tuple(test_tup, test_dict): """ Add a dictionary to the end of a tuple. Args: test_tup (tuple): The original tuple. test_dict (dict): The dictionary to add. Returns: tuple: A new tuple with the dictionary added. """ # Your code here pass