How to find all files with a particular extension? [duplicate] April 8, 2024 by Tarik try changing the inner loop to something like this results += [each for each in os.listdir(folder) if each.endswith('.c')]