Is this serialized (hex-encoded) transaction a segwit transaction?

def btc_tx_is_segwit( tx_serialized ):
    """
    Is this serialized (hex-encoded) transaction a segwit transaction?
    """
    marker_offset = 4       # 5th byte is the marker byte
    flag_offset = 5         # 6th byte is the flag byte
    
    marker_byte_string = tx_serialized[2*marker_offset:2*(marker_offset+1)]
    flag_byte_string = tx_serialized[2*flag_offset:2*(flag_offset+1)]

    if marker_byte_string == '00' and flag_byte_string != '00':
        # segwit (per BIP144)
        return True
    else:
        return False