교육/파이썬빅데이터분석교육
퀴즈 6.10 소스
빅데이터 김교수
2022. 5. 18. 13:43
people = ['홍', '홍', '김', '이', '홍', '김']
def max_count(people):
counts = {} # 집합, set
for i in people:
if i in counts:
counts[i] += 1
else:
counts[i] = 1
return counts
counts = max_count(people)# 호출함수
first = []
max_num = max(counts.values()) # 가장 높은 값
for name, count in counts.items():
print(name, ':', count,'번')
if count == max_num :
first.append(name)
print('1등:', first)
반응형