Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.

image text in transcribed

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

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

Step: 3

blur-text-image

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

Spatial Database Systems Design Implementation And Project Management

Authors: Albert K.W. Yeung, G. Brent Hall

1st Edition

1402053932, 978-1402053931

More Books

Students also viewed these Databases questions

Question

Use of assessments to determine trainees learning styles.

Answered: 1 week ago

Question

7. Discuss the advantages of embedded learning.

Answered: 1 week ago