human
Complete this python program:
def isSane(totalLen, payloadLen, flags):
assistant
#Here is the Python code you requested.

    """Verifies whether the given header fields are sane.
    The values of the fields `totalLen\, `payloadLen\ and `flags\ are checked
    for their sanity.  If they are in the expected range, `True\ is returned.
    If any of these fields has an invalid value, `False\ is returned.
    """
    def isFine(length):
        '\n                                Check    if    the    given    length    is    fine.\n                                '
        return (True if (0 <= length <= const.MPU) else False)
    validFlags = [const.FLAG_PAYLOAD, const.FLAG_NEW_TICKET, const.FLAG_PRNG_SEED]
    return (isFine(totalLen) and isFine(payloadLen) and (totalLen >= payloadLen) and (flags in validFlags))