def recursiveSearch(rootDir):
file = 'foundMe'
# Creates a full path back to the root directory with each item in list
for p in os.listdir(rootDir):
path = os.path.join(rootDir, p)
if os.path.isfile(path):
if os.path.splitext(os.path.basename(path))[0] == file:
print("congrats you found", path)
return path
else:
if os.path.isdir(path):
recursiveSearch(path)
x = recursiveSearch(rootDir)
print(x) ->>> None
Why does this function return the None type and not the path of the file that I have found?
When I run the function, the recursion works and is able to find and print the path to the file, but nothing is returned. Could someone please explain why?