Sobes.tech
Junior — Senior

Recursive file search by pattern with logging capability

livecode

Task condition

Create a function that takes two arguments: a directory path and a filename pattern. The function should return a list of all files matching the pattern, found in the specified directory and all its subdirectories. Implement an optional logging feature that outputs to the console each visited directory and the names of found files if this option is enabled.

def find_files(root_path: str, pattern: str, log: bool = False) -> List[str]:
    # function implementation
    pass