def extend_knots(internal_knots, k):
    """
    Extend the knots sequence to add the external knots. This is done because
    :meth:`extract_coeffs_knots_from_splines` returns only the internal knots.
    Therefore they should be extended on both sides by **k** knots.

    :param internal_knots: [array] containing the internal knots
    :param k: [int] spline degree
    :return: [list] containing the extended knots
    """
    extended_knots = []
    for i in range(k):
        extended_knots.append(internal_knots[0])
    extended_knots += list(internal_knots)
    for i in range(k):
        extended_knots.append(internal_knots[-1])
    return extended_knots