def rule_func(var_list, dataset, rule):
    """Function for applying data management rule on dataset with given variable names.
    Variable names should match with dataset's column names.

    Defined rules are exclusion, conversion and length generation.

    Exclusion(exclude) rule excludes variable from the dataset.

    Conversion(convert) rule converts "f" and "t" values into 0 and 1 respectively.
    Thus variable should have values either "f" or "t".

    Length generator(lengthen) rule gets the string lenght,
    adds "_len" to variable name and exclude variable from dataset.

    Args:
        | var_list (list): list of variables to apply
        | dataset (pd.Dataframe): dataset to implement the rule
        | rule (str): can take values 'exclude', 'convert' or 'lengthen'

    Returns:
        the altered dataset (pd.Dataframe)
    """

    if rule == "exclude":
        dataset = dataset.drop(var_list, axis=1)

    elif rule == "convert":
        for c in var_list:
            dataset[c] = dataset[c].replace({"f": 0, "t": 1})

    elif rule == "lengthen":
        for l in var_list:
            dataset[l + "_len"] = dataset[l].str.len()
            dataset = dataset.drop(l, axis=1)

    else:
        raise ValueError("Rule is not defined")

    return dataset