def level_to_session(level):
    """
    Converts study level to a year of study. 

    Intended for use with the level descriptions that come out of the 
    HE In Year Cohort web report, but applicable to other instances. 

    Parameters
    ----------
    level : str
        The text version of a level. Should begin with the word 'level'.

    Returns
    -------
    int
        The year of study that the level (typically) corresponds to.
    """

    session = "X"
    if level[:5].upper() == "LEVEL":
        session = int(level[-1]) - 3
    else:
        session = 1
    return session