How do I search the folders and subfolders using recursion?

I've been working through the Edube course Python Essentials 2. In module 4.4.1.8, there's a lab that asks you to create a find function that searches recursively for a directory in all folders and subfolders starting from a given path.

The function takes two arguments, the starting path and the directory whose name you're searching for. You're supposed to return the absolute path for all folders matching the input directory. I have managed to get a function that recursively heads down one branch of the tree, but I can't get it to do the other branches. I'm trying to do this using a for loop. Any suggestions?

Posted Oct 1, 2025, 8:58 PM UTC

27
Loading comments…