human
function to round to variable number of digits.
assistant
Here is a Python function to round to a variable number of digits

import math

def round_to_n_digits(number, n):
    """Rounds number to n digits.

    Args:
        number (float): Number to round.
        n (int): Number of digits to round to.

    Returns:
        float: Rounded number.
    """
    return round(number, n)

# Enter the number
number = 123.456789

# Enter the number of digits
n = 3

# Calling the function
print((round_to_n_digits(number, n)))

#Example Output
# 123.457

#Remember to inspect code for bugs.