import os path = os.getcwd() for i in range(0,40): file_path = path + '\\'+ str(i) os.mkdir(file_path)