def pickrun(files, whichrun):
    """pick file from list of files"""
    filemap = {'first': 0, 'last': -1, 'middle': len(files) // 2}
    if isinstance(files, list):
        if isinstance(whichrun, int):
            return files[whichrun]
        elif isinstance(whichrun, str):
            if whichrun not in filemap.keys():
                raise (KeyError,
                    'Sorry, whichrun must be either integer indexor string in form of "first", "last" or "middle'
                    )
            else:
                return files[filemap[whichrun]]
    else:
        return files
