delicious cats catnames txt zophie jpg walnut waffles butter txt spam txt figure - an example folder that contains three folders and four files here is an example program that uses the os walk(function on the directory tree from figure - import os for foldernamesubfoldersfilenames in os walk(' :\\delicious')print('the current folder is foldernamefor subfolder in subfoldersprint('subfolder of foldername 'subfolderfor filename in filenamesprint('file inside foldername ''filenameprint(''the os walk(function is passed single string valuethe path of folder you can use os walk(in for loop statement to walk directory treemuch like how you can use the range(function to walk over range of numbers unlike range()the os walk(function will return three values on each iteration through the loopa string of the current folder' name list of strings of the folders in the current folder list of strings of the files in the current folder (by current folderi mean the folder for the current iteration of the for loop the current working directory of the program is not changed by os walk(