<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def construct_notebook_index(title, pthlst, pthidx):
 """ Construct a string containing a markdown format index for the list of paths in `pthlst`. The title for the index is in `title`, and `pthidx` is a dict giving label text for each path. """


    # Insert title text
    txt = '"""\n## %s\n"""\n\n"""' % title
    # Insert entry for each item in pthlst
    for pth in pthlst:
        # If pth refers to a .py file, replace .py with .ipynb, otherwise
        # assume it's a directory name and append '/index.ipynb'
        if pth[-3:] == '.py':
            link = os.path.splitext(pth)[0] + '.ipynb'
        else:
            link = os.path.join(pth, 'index.ipynb')
        txt += '- [%s](%s)\n' % (pthidx[pth], link)
    txt += '"""'
    return txt