<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def extract(environ, empty=False, err=False):
 """Extracts strings in form data and returns a dict. :param environ: WSGI environ :param empty: Stops on empty fields (default: Fault) :param err: Stops on errors in fields (default: Fault) """

    formdata = cgi.parse(environ['wsgi.input'], environ, empty, err)
    # Remove single entries from lists
    for key, value in iter(formdata.items()):
        if len(value) == 1:
            formdata[key] = value[0]
    return formdata