from collections import Counter
lst = ['apple', 'mango', 'banana','mango', 'apple', 'banana',
'mango', 'suhuni']
ret = dict(Counter(lst))
print(ret) # {'apple': 2, 'mango': 3, 'banana': 2, 'suhuni': 1}
ret = sorted(ret.items(), key = lambda x:x[1], reverse=True)
print(ret) # [('mango', 3), ('apple', 2), ('banana', 2), ('suhuni', 1)]
print(f'{ret[0][0]}가 {ret[0][1]}번 최다 등장했다!') # mango가 3번 최다 등장했다!
st = 'an applemango'
st_dict = dict(Counter(st))
sorted_st = sorted(st_dict.items(), key= lambda x:x[1], reverse=True)
print(f'{sorted_st[0][0]}가 최다 {sorted_st[0][1]}번 사용됨')
counter 를 이용해 시퀀스에서 중복된 값의 개수를 빠르게 구하는 것과,
내장함수 sorted에서 정렬 기준을 정하는 것을 연습했다!