0 out of 464 challenges solved

Rotate List Right

Write a function `rotate_right(lst, m)` that takes a list `lst` and an integer `m` as input and returns a new list that is the result of rotating the original list `m` positions to the right.

For example:

```python [main.nopy]
rotate_right([1, 2, 3, 4, 5], 2)  # Output: [4, 5, 1, 2, 3]
rotate_right([1, 2, 3, 4, 5], 0)  # Output: [1, 2, 3, 4, 5]
rotate_right([1, 2, 3, 4, 5], 5)  # Output: [1, 2, 3, 4, 5]
rotate_right([1, 2, 3, 4, 5], 7)  # Output: [4, 5, 1, 2, 3]
```

#### Requirements:
- The function should handle cases where `m` is greater than the length of the list.
- The function should not modify the original list.
- The function should handle empty lists gracefully.

#### Constraints:
- The input list can contain any type of elements.
- The integer `m` can be any non-negative integer.

#### Example Usage:
```python [main.nopy]
rotate_right([1, 2, 3, 4, 5], 3)  # Output: [3, 4, 5, 1, 2]
rotate_right([], 3)  # Output: []
rotate_right([1], 10)  # Output: [1]
```
def rotate_right(lst, m):
    """
    Rotates the list `lst` to the right by `m` positions.

    Args:
        lst (list): The list to rotate.
        m (int): The number of positions to rotate.

    Returns:
        list: The rotated list.
    """
    # Placeholder for the solution
    pass