code: def list_files(dirname, extension=None):
      
      f = []
      for (dirpath, dirnames, filenames) in os.walk(dirname):
          f.extend(filenames)
          break
      if extension is not None:
          # Filter on extension
          filtered = []
          for filename in f:
              fn, ext = os.path.splitext(filename)
              if ext.lower() == '.' + extension.lower():
                  filtered.append(filename)
          f = filtered
      return f
docs: List all files in directory `dirname`, option to filter on file extension