교육/파이썬빅데이터분석교육
퀴즈 6.6 답 파이썬 함수 생성_ 영어, 한글 단어 수를 세는 연습문제풀이
빅데이터 김교수
2022. 5. 11. 16:22
정답 :
text = "AI! 나는 인공지능 로봇 입니다. 나는 'AI 로봇' 입니다."
def max_counts(text):
skips =['.', ',', ';', ':', "'", '!']
for ch in skips:
text= text.replace(ch, '')
counts={}
for i in text.split(' '):
if i in counts:
counts[i] += 1
else:
counts[i] =1
return counts
max_counts(text)
반응형