<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def kxtrct(keywd, terms, nterms, instring, termlen=_default_len_out, stringlen=_default_len_out, substrlen=_default_len_out):
 """ Locate a keyword in a string and extract the substring from the beginning of the first word following the keyword to the beginning of the first subsequent recognized terminator of a list. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/kxtrct_c.html :param keywd: Word that marks the beginning of text of interest. :type keywd: str :param terms: Set of words, any of which marks the end of text. :type terms: Array of str :param nterms: Number of terms. :type nterms: int :param instring: String containing a sequence of words. :type instring: str :param termlen: Length of strings in string array term. :type termlen: int :param stringlen: Available space in argument string. :type stringlen: int :param substrlen: Available space in output substring. :type substrlen: int :return: String containing a sequence of words, String from end of keywd to beginning of first terms item found. :rtype: tuple """

    assert nterms <= len(terms)
    # Python strings and string arrays => to C char pointers
    keywd = stypes.stringToCharP(keywd)
    terms = stypes.listToCharArrayPtr([s[:termlen-1] for s in terms[:nterms]],xLen=termlen,yLen=nterms)
    instring = stypes.stringToCharP(instring[:stringlen-1],inlen=stringlen)
    substr = stypes.stringToCharP(substrlen)
    # Python ints => to C ints
    termlen = ctypes.c_int(termlen)
    nterms = ctypes.c_int(nterms)
    stringlen = ctypes.c_int(stringlen)
    substrlen = ctypes.c_int(substrlen)
    found = ctypes.c_int()
    libspice.kxtrct_c(keywd, termlen, terms, nterms,
                      stringlen, substrlen, instring, ctypes.byref(found),
                      substr)
    return stypes.toPythonString(instring), stypes.toPythonString(
            substr), bool(found.value)