How do I get rid of these nested for loops in my code? I have tried to use list comprehension but didn't manage to create anything good. Thank you for your help! Here's part of my code:
folders = [i for i in range(1, int(number_of_folders) + 1)]
subfolders = [i for i in range(1, int(number_of_subfolders) + 1)]
files = [i for i in range(1, int(number_of_files) + 1)]
for i in folders:
folderpath = path + "/folder-" + str(i)
for j in subfolders:
subfolderpath = folderpath + "/subfolder-" + str(j)
os.makedirs(subfolderpath)
for k in files:
file_path = subfolderpath + "/files-" + str(j) + '-' + str(k) + ".txt"
open(file_path, "w")