def sigfig(number, digits=3):
    """
    Round a number to the given number of significant digits.
    Example:
        >>> sigfig(1234, 3)
        1230

    number (int or float): The number to adjust
    digits=3 (int): The number of siginficant figures to retain

    Returns a number."""

    input_type = type(number)
    output_num = ''
    digit_count = 0
    period_found = False
    for digit in str(float(number)):
        if digit == '.':
            period_found = True
            output_num += '.'
        elif digit_count < digits:
            output_num += digit
            digit_count += 1
        else:
            output_num += '0'

    return input_type(float(output_num))