[Python] list 최빈값 구하기
from collections import Counter n_list = list(map(int, input().split()))# 1 1 2 2 2 2 2 3 3 4 4 4 4 4 4 4 4 5 cnt = Counter(n_list)# Counter({4: 8, 2: 5, 1: 2, 3: 2, 5: 1}) cnt = cnt.most_common()# [(2, 5), (4, 4), (3, 3), (1, 2), (5, 2)] print(cnt[0][0])# 2