The following code returns a list of file-names in a given directory: How can I make it return absolute file paths with minimal modification and preserve the behavior of the function? Answer The easiest way to do this is with pathlib Make your input directory a Path object, use .iterdir() to get all the files/folders inside that directory, use .absolute()