In: Computer Science
Using Python create a script called create_notes_drs.py. In the file, define and call a function called main that does the following:
Bonus Challenge: Add a conditional statement to abort the script if the directory CyberSecurity-Notes already exists.
Here is the completed code for this problem. Comments are included, go through it, learn how things work and let me know if you have any doubts or if you need anything to change. If you are satisfied with the solution, please rate the answer. Thanks
#code
import os
def main():
#storing main directory name
root = 'CyberSecurity-Notes'
#if directory already exists,
returning from method, doing nothing
if
os.path.isdir(root):
return
#creating main directory
os.mkdir(root)
#looping from 1 to 24
for week
in range(1, 25):
#creating sub
directory named Week n, where n is a value between 1 and 24
os.mkdir('{}/Week {}'.format(root, week))
#looping from 1 to
3
for day in range(1, 4):
#within this sub directory, creating sub directory named Day
n,
# where n is between 1 and 3
os.mkdir('{}/Week {}/Day {}'.format(root, week,
day))
#calling main()
main()
#output (partial)