I build
totalset = {}
and extract the file names from folders A, B, C, D by
for file_name in (os.listdir(full_subdir_name)):
full_file_name = os.path.join(full_subdir_name, file_name)
Now I want to build something called namelist that contains all the file names, and I could traverse all the files in the folders through:
for file in namelist[A]:
blabla...
for file in namelist[B]:
blabla.. .
What should I do?
You should probably use a “list comprehension”. Here is an example of how you could do it:
So then you would build the full
namelistsomething like this. First you should set up a list of names.Once you have
lst_namesset up with your names, build the fullnamelist:Personally I think it would be easier to read with a shorter variable name than
full_subdir_name: