def monthCode(month):
    codes = ('F','G','H','J','K','M','N','Q','U','V','X','Z')
    
    if isinstance(month,int):
        return codes[month-1]
    elif isinstance(month,str):
        return codes.index(month)+1
    else:
        raise ValueError('Function accepts int or str')
perform month->code and back conversion
dataset/ETHPy150Open sjev/trading-with-python/lib/cboe.py/monthCode