Create the function to change the element positions with the same exact logics: Input: ["tail", "body", "head"] Output: ["head", "body", "tail"] Input: ["tails", "body", "heads"] Output: ["heads", "body", "tails"] Input: ["bottom", "middle", "top"] Output: ["top", "middle", "bottom"] Input: ["lower legs", "torso", "upper legs"] Output: ["upper legs", "torso", "lower legs"] Input: ["ground", "rainbow", "sky"] Output: ["sky", "rainbow", "ground"]
def switch_elements(arr): return [arr[-1]] + arr[1:-1] + [arr[0]]