Question
Implement a recursive function findAll () that takes as parameters the name of a file and the pathname of a folder and searches for the
Implement a recursive function findAll() that takes as parameters the name of a file and the pathname of a folder and searches for the file in the folder and any folder contained within it, directly or indirectly. The function should return a list containing the full pathname of all occurrences of the file. All possible capitalizations of the file name should be considered when accumulating the list. Please note that your function must work as described on any directory structure, not just the one provided as an example. Note that a correct solution to this problem will involve a variable that is initialized at the top of the function, modified over each branch of the function, and returned only at the end. The following illustrates several searches using a sample set of folders and directories located in the zip file containing the assignment template.
the solution must create a variable that is modified and only returned at the end.
This is the output and in python please.
Python 3.6.4 Shell File Edit She Debug Options Window Help >>> lst = findA ? ?(lfile.txt', 'ne s ted') >>>lst ?nested) \ fi 1 e . txt ,, ,nes ted) \ tes t 1 3.5 tes t 1 1 ? \ tes t 1 1 1 3.5 fi le . txt', 'nested)test1)tes t 123.5 test121file.txt', 'nested test1 test 12 test 1211test1211file.txt', 'nested\ test2 file.txt', 'nestedtest3\\file.txt',nested test3 test31file.txt', nested test3 test32file.txt', 'nestedtest3test32test321 test3211file.txt' >>> lstfindAll(TESTfile2.PY', 'testpath') >>>lst ' testpath\\directoryB\\directoryB21testfile2.py ] >>> lst findA11(' gertrude . jpg', 'testdirs') >>>lst ['testdirsWfolde r 1WFolde r 1WFOLDER2 W gertrude . jpg', 'testdirsWfolder1Wgertrude . jpg testdirs\\folder2gertrude.jpg' >>> lst findll(FILEA.txt', 'testdirs') >>>lst ['testdirsWfileA.txt', 'testdirsWfolde r 1WFolde r 1WfileA.txt', 'testdirsWfolder2WFILE A.txt'] >>>lst 'test') >>> lst = findA ? ?('fileD.txt', >>>lst ['test\folder1 folder11\fileD.txt', 'test folder2 fileD.txt' Ln: 43 Col: 4
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started