You can use the functions of Python module 'os' to scan a directory to find folders and files in it.
Here is an example to find the list of folders and files inside a folder:
import osdir_list = []fl_list = []for f in os.scandir(os.getcwd()): # replace 'os.getcwd()' with path to your folder if os.DirEntry.is_dir(f): dir_list.append(f.name) elif os.DirEntry.is_file(f): fl_list.append(f.name)print("All directories: ", dir_list)print("All files: ", fl_list)