Question: PYTHON Implement the recursive function traverse () that takes as input a pathname of a folder (as a String) and an Integer d and prints
PYTHON
Implement the recursive function traverse () that takes as input a pathname of a folder (as a String) and an Integer d and prints on the screen the pathname of every file and subfolder contained in the folder, directly or indirectly. The file and subfolder pathnames should be output with an indentation that proportional to their depth with respect to the topmost folder. The next example illustrates the execution of traverse on the folder test shown in below. using a loop (NOT recursion)
>>> traverse(test,0)
test/fileA.txt
test/folder1
test/folder1/fileB.txt
test/folder1/fileC.txt
test/folder1/folder11
test/folder1/folder11/fileD.txt
test/folder2
test/folder2/fileD.txt
test/folder2/file.E.txt
PYTHON only please. I dont know any other language
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
