From 6c275b043620746b429d8d7b852a8e7f7b595b70 Mon Sep 17 00:00:00 2001 From: Chapin Bryce <27cbryce@gmail.com> Date: Sat, 15 Jun 2019 17:03:03 -0400 Subject: [PATCH] Updates to recursion script --- sections/section_01/recursion_example.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sections/section_01/recursion_example.py b/sections/section_01/recursion_example.py index 63c8f93..479a1bc 100644 --- a/sections/section_01/recursion_example.py +++ b/sections/section_01/recursion_example.py @@ -100,11 +100,17 @@ def iterate_files(path): # To effectively reference a file, you should include # the below line which creates a full path reference # to the specific file, regardless of how nested it is - file_entry = os.path.join(root, file_entry) + file_entry = os.path.join(root, fentry) # We can then hand `file_entry` off to other functions. if file_entry.endswith('py'): num_py_files += 1 + print(f"Number of folders: {num_folders}") + print(f"Number of files: {num_files}") + print(f"Number of Python files: {num_py_files}") if __name__ == "__main__": + abspath = os.path.abspath + print(f"Listing {abspath('.')}") list_directory('.') + print(f"Recurively counting files in {abspath('../../')}") iterate_files('../../')