def fill_nan(df,list):
    """
    Fill nan values with either mean or mode

    Parameters
    ----------
    df : dataframe
        dataframe used for checking and filling nan values
    list: list
        list of columns to be checked

    Returns
    -------
    df : dataframe
        modified dataframe with no nan values
    """
    for col in list:
        replacement=df[col].dropna().mean()
        df[col]=df[col].fillna(replacement)
    return df