def get_default_values(number_of_bands, values):
    """Return values for bands

    Utility function to get values (e.g., nodata) for bands.

    For n = number_of_bands:
    - If values is a single value, transform it into a list with n elements
    - If values is a list with size lower than n, extend the list to size n by repeating the last value (n=4, values=[1, 2], result=[1, 2, 2, 2]
    - If values is a list with size greater than n, slice values to values[:n]

    :param number_of_bands: number of bands
    :type number_of_bands: int
    :param values: value or list of values
    :type values: same as raster type
    :return: values
    :rtype: same as input values
    """
    try:
        if number_of_bands < len(values):
            values = values[:number_of_bands]
        elif number_of_bands > len(values):
            values = values[-1] * (number_of_bands - len(values))
    except TypeError:
        values = [values] * number_of_bands
    except:
        raise
    return values
