Why is this recursive function returning more than 1 dictionary aka printing them each time it cycles why isn't it adding new findings to the existing dictionary.
And no i dont want to use os.walk and yes i am aware theres no return
def retFiles(dir):
data = {}
root = set()
os.chdir(dir)
cwd = os.getcwd()
for i in os.listdir(cwd):
if os.path.isfile(i):
data.setdefault(i, set())
root.add(os.path.relpath(dir).replace("\\", "/"))
data[i] = root
else:
retFiles(i)
print(data)