0 out of 464 challenges solved
Write a Python function `split_and_rearrange(lst, n)` that takes a list `lst` and an integer `n` as input. The function should split the list at the `n`th index and rearrange it such that the first part of the list is moved to the end. #### Example Usage ```python [main.nopy] split_and_rearrange([12, 10, 5, 6, 52, 36], 2) # Output: [5, 6, 52, 36, 12, 10] split_and_rearrange([1, 2, 3, 4], 1) # Output: [2, 3, 4, 1] split_and_rearrange([0, 1, 2, 3, 4, 5, 6, 7], 3) # Output: [3, 4, 5, 6, 7, 0, 1, 2] ``` #### Constraints - The input list `lst` will have at least one element. - The integer `n` will be a valid index within the range of the list. - The function should not modify the original list.
def split_and_rearrange(lst, n): """ Splits the list at the nth index and rearranges it such that the first part is moved to the end. Args: lst (list): The input list to be rearranged. n (int): The index at which to split the list. Returns: list: The rearranged list. """ # Implement the function logic here pass