def rotate_string(string: str, n: int) -> str:
    """
    Given a string and an integer n, rotate it by removing n characters from the end
        and placing them at the beginning. If n is negative, removes from the beginning
        and places at the end.

    Args:
        string (str): the string to rotate
        n (int): the number of characters to rotate

    Returns:
        string: the rotated string

    Raises:
        IndexError: You cannot rotate the string by more than its length!
    """
    if abs(n) > len(string):
        raise IndexError("You cannot rotate the string by more than its length!")
    return string[-n:] + string[:-n]