for sec in 'abdcef' if section[sec=wall walldict pastewalldict(closed[sec]walldict paste_closed_to[sec][ ]paste_closed_to[sec][ ] draw the exit sign if needed if section[' '=exit walldict pastewalldict(exit_dictwalldict if section[' '=exit walldict pastewalldict(exit_dictwalldict if section[' '=exit walldict pastewalldict(exit_dictwalldict return walldict print('maze runner dby al sweigart al@inventwithpython com' print('(maze files are generated by mazemakerrec py)' get the maze file' filename from the user while true print('enter the filename of the maze (or list or quit):' filename input('' list all the maze files in the current folder if filename upper(='list' print('maze files found in'os getcwd() for fileincurrentfolder in os listdir() if (fileincurrentfolder startswith('maze' and fileincurrentfolder endswith(txt')) print('fileincurrentfolder continue if filename upper(='quit' sys exit( if os path exists(filename) break print('there is no file named'filename load the maze from file mazefile open(filename maze { lines mazefile readlines( px none py none exitx none exity none for line in lines width len(line rstrip() for xcharacter in enumerate(line rstrip()) assert character in (wallemptystartexit)'invalid character at column {}line {}format( if character in (wallempty)maze runner