<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def autocorrect(query, possibilities, delta=0.75):
 """Attempts to figure out what possibility the query is This autocorrect function is rather simple right now with plans for later improvement. Right now, it just attempts to finish spelling a word as much as possible, and then determines which possibility is closest to said word. Args: query (unicode):
 query to attempt to complete possibilities (list):
 list of unicodes of possible answers for query delta (float):
 Minimum delta similarity between query and any given possibility for possibility to be considered. Delta used by difflib.get_close_matches(). Returns: unicode: best guess of correct answer Raises: AssertionError: raised if no matches found Example: .. code-block:: Python 'bowtie2' """


    # TODO: Make this way more robust and awesome using probability, n-grams?

    possibilities = [possibility.lower() for possibility in possibilities]

    # Don't waste time for exact matches
    if query in possibilities:
        return query

    # Complete query as much as possible
    options = [word for word in possibilities if word.startswith(query)]
    if len(options) > 0:
        possibilities = options
        query = max_substring(options)

    # Identify possible matches and return best match
    matches = get_close_matches(query, possibilities, cutoff=delta)

    # Raise error if no matches
    try:
        assert len(matches) > 0
    except AssertionError:
        raise AssertionError('No matches for "{0}" found'.format(query))

    return matches[0]