Feb-14-2021, 03:13 AM
You could do it by using some flow_control with for/else. But I found that a little bit clumsy when I tried. So I might prefer to just use a sentinel variable and check it after each time you finish with a zip file. If you've found a match, use the variable to decide if you need to look at another one.
processed_zip_file = False for zip_file in time_sorted_list: for inside_file in ZipFile(zip_file, "r").namelist(): if "Debug_ITU" in inside_file: # want to copy this one. Do what is necessary to create dst shutil.copy(zip_file, dst) processed_zip_file = True break if processed_zip_file: break