Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

``` 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

More Books

Students also viewed these Programming questions