0 out of 464 challenges solved
Write a function `replace_last_element` that takes in two lists, `list1` and `list2`. The function should replace the last element of `list1` with all the elements of `list2`. #### Example Usage ```python [main.nopy] replace_last_element([1, 2, 3], [4, 5]) # Output: [1, 2, 4, 5] replace_last_element(['a', 'b', 'c'], ['x', 'y', 'z']) # Output: ['a', 'b', 'x', 'y', 'z'] replace_last_element([10], [20, 30]) # Output: [20, 30] ```
def replace_last_element(list1, list2): """ Replace the last element of list1 with all elements of list2. Args: list1 (list): The first list. list2 (list): The second list whose elements will replace the last element of list1. Returns: list: The modified list1 with its last element replaced by elements of list2. """ # Replace the last element of list1 with the elements of list2 pass