Python: Parse searched files refactor

Viewed 27

I'm trying to rewrite this in a nested format, or any other suggested format.

files = os.listdir(file_path)
for file_name in [file for file in files if file.startswith(searched_input)]:
    with open(file_path, "r") as file:

A new format, but with new permission errors. PermissionError: [Errno 13] Permission denied:

files = os.listdir(file_path)
for file in files:
    if file.startswith(searched_input):
        with open(file_path, "r") as file:
0 Answers
Related