In this a variable there is a folder called main_folder
.
This folder has two folders:
111
,222
I need to get the names of these folders in a list.
Tried this:
a = r'C:\Users\user\Desktop\main_folder'
import os
for root, dirs, files in os.walk(a):
print(dirs)
gives:
['111', '222'] # <--------------This only needed
[]
[]
How to keep only the first list and not the empty ones which I think describe the contents of these folders since they don't have folders.