Question: ``` import sys import os from os import listdir from os.path import isfile, join from os.path import isdir from pathlib import Path def list ()

```

import sys import os from os import listdir from os.path import isfile, join from os.path import isdir from pathlib import Path def list(): # list of the content of every chosen directory for i in os.listdir(r'C:\Test\\'): # os.listdir will help us to list the content of the respective dir print(i) dir = input("Choose a directory to list its content: ") if Path('C:\\Test\\' + dir).is_dir(): # checks if the directory exists # print("Directory exist") for i in os.listdir('C:\\Test\\' + dir): # we concatenate the previous dir to the chosen directory in order to list the content of that directory print(" " + i) print(" The above is the content of the directory " + dir) else: print("Directory does not exist!") if __name__ == '__main__': list() 

```

I would like to print the information in a table sorted into directory, subdirectory and files (if permits)....

Please if anyone could help me!!!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!