지나가던 개발자

[Python] 백준 1181번(단어 정렬) 문제 풀이 본문

PS/Python

[Python] 백준 1181번(단어 정렬) 문제 풀이

KwonYongHyeon 2022. 1. 20. 15:12

 

words = []
for i in range(int(input())):
    words.append(input())
words = list(set(words))
words.sort()
words.sort(key=len)
for word in words:
    print(word)

 

 리스트.sort(key=len)은 리스트를 길이를 기준으로 정렬하고, 리스트.sort()는 리스트를 알파벳을 기준으로 정렬한다.

Comments