yuns

list에서 개수 세기 본문

python 간단 문법 정리

list에서 개수 세기

yuuuun 2021. 7. 7. 13:59
반응형

collections.Counter

from collections import Counter
ans = Counter(lis)
>> answer
Counter({1: 4, 2: 3, 3: 3, 7: 3, 4: 2, 5: 2, 6: 2, 8: 2, 9: 2, 0: 2})
반응형

'python 간단 문법 정리' 카테고리의 다른 글

string모듈  (0) 2021.07.07
n진수로 나타내기  (0) 2021.07.07
int list to string  (0) 2021.06.17
sort한 다음에 index 반환  (0) 2021.06.15
list key로 정렬하기  (0) 2021.06.02
Comments