I am using an os.walk() loop and if statement to find the path of a file. It works, however after the path is found and printed the loop doesn't break for a few seconds after this. I want to break the loop after the path I want is printed. New to recursion so this is where I am falling short.
Code:
for root, dirs, files in os.walk('C:\\'):
for file in files:
if file == 'vipkidt.exe':
path = str(os.path.join(root, file))
print(path)
Output>> C:\Program Files (x86)\VIPKIDT\vipkidt.exe
# 3-4 seconds passes..
Process finished with exit code 0
Wanted path is printed fairly qucikly, 3-4 seconds passes, then loop breaks. I want these 3-4 seconds shaved off. I have tried adding a break
at each the inner and outer for loop, however didn't do the trick. I referenced these posts here but still wasn't clicking: ref1, ref2