def filter_and_sort(file_list):
 file_list = [filename for filename in file_list if filename.endswith('.py')]
 def key(item):
  return len(item)
 file_list.sort(key=key)
 return file_list

def filter_and_sort ( file_list ) : file_list = [ filename for filename in file_list if filename . endswith ( '.py' ) ] def key ( item ) : return len ( item ) file_list . sort ( key = key ) return file_list
out of a list of file names .