<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def list_tasks(target=None):
 """Returns a list of all the projects and tasks available in the `acorn` database directory. Args: target (str):
 directory to list the projects for. Defaults to the configured database directory. Returns: dict: keys are project names; values are lists of tasks associated with the project. """

    from os import getcwd, chdir
    from glob import glob
    original = getcwd()
    if target is None:# pragma: no cover
        target = _dbdir()
        
    chdir(target)
    result = {}
    for filename in glob("*.*.json"):
        project, task = filename.split('.')[0:2]
        if project not in result:
            result[project] = []
        result[project].append(task)

    #Set the working directory back to what it was.
    chdir(original)
        
    return result