사용언어 : python
defaultdict
사용
defaultdict()
는 객체의 기본값을 딕셔너리값의 초기값으로 지정할 수 있다.
즉 기본값 지정할 때 사용
int,list,set 등으로 초기화 가능
key
를 이용하여 dictionary를 정렬할때에는 밑에 처럼 사용!
sort_dict = sorted(dict.items())
import sys
from collections import defaultdict
n = int(sys.stdin.readline())
result = defaultdict(int)
for _ in range(n):
file = sys.stdin.readline().strip().split('.')
result[file[1]] += 1
result = sorted(result.items())
for x, y in result:
print(x, y)