https://www.acmicpc.net/problem/1157
import sys
from collections import Counter
word=input()
word=word.upper()
count=Counter(word)
most=count.most_common() #most.common() 인자 없는건 내림차순 정렬
maximum=most[0][1]
high=count.most_common(1) #최빈값
modes=[]
for num in most:
if num[1]==maximum:
modes.append(num[0])
if len(modes)>1:
print("?")
else:
print(high[0][0])코드를 입력하세요
word.upper()
word. lower()
입력값이 Aaabbks 일때
count=Counter(word)
print(count)
->Counter({'A': 3, 'B': 2, 'K': 1, 'S': 1})
most=count.most_common()
maximum=most[0][1]
print(maximum)
-> 3
maximum=most[0][1]
0번째 덩어리(?)의 value값
만약 most[0][0]이라면 -> 'A'
만약 most[2][1]이라면 -> 1
for num in most:
if num[1]==maximum:
modes.append(num[0])
num[1] : 3,2,1,1 즉 value값을 모두 도는것
num[0] : A,B,K,S 즉 Key 값을 모두 도는것
(for num in most 이기 때문에)