I'm given a task to detect if there is a file inside a path, if there is no file then sleep and wait until there is a file existing else do the command.
Here is my code
import os,time
path = 'C:\\Users\\test'
for dir, sub_dirs, files in os.walk(path):
while not files:
print("no files at this level")
time.sleep(1)
if files:
print("file detected")
Even I put the file inside the path, it keeps sleeping, it does not print file detected, What is wrong with this?