✔ 풀이를 위한 아이디어
✔ 코드
import sys
words = []
for _ in range(50):
tmp = []
words.append(tmp)
num = int(sys.stdin.readline())
for _ in range(num):
word = sys.stdin.readline()
words[len(word)-2].append(word)
for i in range(len(words)):
if len(words[i]) == 1:
print(words[i][0], end="")
elif len(words[i]) > 1:
words[i] = sorted(words[i])
new_list = []
for v in words[i]:
if v not in new_list:
new_list.append(v)
words[i] = new_list
for j in range(len(words[i])):
print(words[i][j], end="")