Function Use: To print all the directories in a folder/sub-folder or directory import os def get_list_or_dir(local_dir): for dir_or_file in os.listdir(local_dir): if os.path.isdir(dir_or_file): path = os.path.join(local_dir, dir_or_file) print(dir_or_file, 'This is a directory') get_list_or_dir(path) else: print(dir_or_file) Path = os.getcwd() or define the path from where you need a file Function Call: get_list_or_dir(path)
You guys can get this programming question from Project Euler. The code for this ask is : for a in range(1,1000): for b in range(1,1000): c = math.sqrt(a*a + b*b) if a + b + c == 1000.0: print a*b*c You guys will get the answer once you execute the code.