Write a recursive method, as a parameter to accept the folder name (absolute or relative to the current folder) that prints lists of all the files and all folders in the folder, which is given in parameter, and displays all folders in all subfolders, ... Output, the entire tree structure of files and folders.
Before each folder should be "*", before each file "-". From the shift should be apparent how deep into the tree, the file / folder is located.
* Romantic songs
- Do you love me.mp3
- When we meet.mp3
- The kid.xvid
Nice job but it still doesn't work like I want to. For example... on my desktop I have a file Pictures. In it, there are files Seaside, Wedding and New Year. And in all of them there are pictures. I want that this pictures would also be printed on my screen. Now it prints only *Pictures and then -Seaside -Wedding -New Year. But these files (Seaside, Wedding,...) should also be written with * because they're files :) Do you understand what I mean?
I really thought I understand recursion... but when I got this method to write, my whole knowledge disappeared :(
I noticed after posting that you got the logic little messed up, but you get the right idea how the recursion works. But you have to have basic case first, the files should be printed for the file list and only recurse to the directories. Maybe better to use os.path.walk with for. Then you do not need to reimplement the walk. (If it is not required by others)