def session_indexed(s: list):
    """
    Converts a session (of actions) to indices and adds start/end tokens

    :param s: list of actions in a session (i.e 'add','detail', etc)
    :return: list of actions as indices
    """
    # assign an integer to each possible action token
    action_to_idx = {'start': 0, 'end': 1, 'add': 2,
                     'remove': 3, 'purchase': 4, 'detail': 5, 'view': 6}
    return [action_to_idx['start']] + [action_to_idx[e] for e in s] + [action_to_idx['end']]