PYTHONdefaultdict: 카운트 누적, 그룹핑, 키존재 상관 없을 때 # 일반 dictionary d = {}for c in s: if c in d: d[c] += 1 else: d[c] = 1# d[c] = d.get(c, 0) + 1 위와 같이 일반 딕셔너리와 다르게, defaultdict을 사용하여 키가 없을 때 자동으로 기본값을 만들 수 있다.이는 get() 함수와 유사하다.기본값이 0이어야 할 때, defaultdict(int)를 사용하며, 괄호 안에 list나 set을 사용하여 value의 형태를 조절할 수 있다.from collections import defaultdictd = defaultdict(int)for c in s: d[c] ..