Question: implement a recursive function with signature find ( path , filename ) that reports all entries of the file system rooted at the given path
implement a recursive function with signature findpath filename that reports all entries of the file system rooted at the given path relative path ie from wherever the program is located having the given file name partial match
Use the base code given below and write the program in Python:
import os
# Assignment: Programming Project P
def findpath filename:
This function searches for a specific filename in a given path using recursion.
Parameters:
path str: The root path from which the search should begin.
filename str: The filename to search for. A partial match is sufficient.
Returns:
None. The function should print the full path of each matching file.
# WRITE YOUR CODE HERE
# Hint: You can use oslistdirpath to get a list of all files and directories in 'path'.
# For each entry in this list, use ospath.joinpath entry to get the full path.
# Check if this path ends with 'filename'. If it does, print the path.
# If the entry is a directory, call the 'find' function recursively with the new path.
if namemain:
path TDir # from current directory check inside TDir folder
filename docx" # All word ducuments
findpath filename
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
