def turn(orient_index, direction):
    """
    change the current orientation according to
    the new directions

    Args:
        orient_index (int): index in the orient list for the
           current orientations
        direction (str): R or L

    Returns:
        int

    """
    if direction == 'R':
        orient_index += 1
        if orient_index == 4:
            orient_index = 0
    else:
        orient_index -= 1
        if orient_index == -1:
            orient_index = 3
    return orient_index