will print the filename of the file that would have been deleted running this version of the program first will show you that you've accidentally told the program to delete rxt files instead of txt files once you are certain the program works as intendeddelete the print(filenameline and uncomment the os unlink(filenameline then run the program again to actually delete the files safe deletes with the send trash module since python' built-in shutil rmtree(function irreversibly deletes files and foldersit can be dangerous to use much better way to delete files and folders is with the third-party send trash module you can install this module by running pip install --user send trash from terminal window (see appendix for more in-depth explanation of how to install third-party modules using send trash is much safer than python' regular delete functionsbecause it will send folders and files to your computer' trash or recycle bin instead of permanently deleting them if bug in your program deletes something with send trash you didn' intend to deleteyou can later restore it from the recycle bin after you have installed send trashenter the following into the interactive shellimport send trash baconfile open('bacon txt'' 'creates the file baconfile write('bacon is not vegetable ' baconfile close(send trash send trash('bacon txt'in generalyou should always use the send trash send trash(function to delete files and folders but while sending files to the recycle bin lets you recover them laterit will not free up disk space like permanently deleting them does if you want your program to free up disk spaceuse the os and shutil functions for deleting files and folders note that the send trash(function can only send files to the recycle binit cannot pull files out of it walking directory tree say you want to rename every file in some folder and also every file in every subfolder of that folder that isyou want to walk through the directory treetouching each file as you go writing program to do this could get trickyfortunatelypython provides function to handle this process for you let' look at the :\delicious folder with its contentsshown in figure - organizing files