fork download
  1. # your code goes here
  2. dict_words = {}
  3.  
  4. for _ in range(int(input())):
  5. word = input()
  6. dict_words[f'{len(word)}'] = dict_words[f'{len(word)}']+[word] if f'{len(word)}' in dict_words.keys() else [word]
  7.  
  8. for key in sorted(dict_words.keys()):
  9. print(*sorted(set(dict_words[key])), sep='\n')
Success #stdin #stdout 0.03s 9928KB
stdin
4
a
avabab
ababababa
abcbacbacbac
stdout
a
abcbacbacbac
avabab
ababababa