def to_n_class(digit_lst, data, labels):
    """to make a subset of MNIST dataset, which has particular digits
    Parameters
    ----------
    digit_lst : list
        for example, [0,1,2] or [1, 5, 8]
    data : numpy.array, shape (n_samples, n_features)
    labels : numpy.array or list of str
    Returns
    -------
    numpy.array, list of int
    """
    if not set(digit_lst) <= set(range(10)):
        raise ValueError
    indices = []
    new_labels = []
    for i, x in enumerate(data):
        for digit in digit_lst:
            if labels[i] == str(digit):
                indices.append(i)
                new_labels.append(digit)

    return data[indices], new_labels