import collections
my_list = [1, 2, 3, 4, 5, 6, 7, 8, 7, 9, 1, 2, 3, 3, 5, 2, 6, 8, 9, 0, 1, 1, 4, 7, 0]
answer = collections.Counter(my_list)
print(answer[1]) # = 4
print(answer[3]) # = 3
print(answer[100]) # = 0
📌 collections
: 데이터 구조 및 여러 도구 제공
내장 데이터 타입 확장 버전을 제공하여 특정 작업을 쉽게 수행할 수 있도록 함
Counter, defaultdict, namedtuple, deque, orderedDict
mystr에서 가장 많이 등장하는 알파벳만을 사전 순으로 출력하는 코드
from collections import Counter
my_str = input().strip()
max_count = max(Counter(my_str).values())
print(''.join(sorted([k for k,v in Counter(my_str).items() if v == max_count])))
input output
'aab' 'a'
'dfdefdgf' 'df'
'bbaa' 'ab'