for filename in os.listdir(p):
flag_possible = True
for c in self.list_contain:
if c not in filename:
flag_possible = False
break
for n in self.list_not_contain:
if n in filename:
flag_possible = False
break
After Change
for filename in os.listdir(p):
if any(c not in filename for c in self.list_contain):
continue
if any(c in filename for c in self.list_not_contain):
continue
full_file_name = os.path.join(p, filename)
list_final.append(full_file_name)
name_list_final.append(
self.list_subjects_potential(filename))