题目:
请实现一个wordcount函数,统计英文字符串中每个单词出现的次数。返回一个字典,key为单词,value为对应单词出现的次数。
Eg:
Input:
"""Hello world! This is an example. Word count is fun. Is it fun to count words? Yes, it is fun!"""
Output:
{'hello': 1, 'world': 1, 'this': 1, 'is': 4, 'an': 1, 'example': 1, 'word': 1, 'count': 2, 'fun': 3, 'it': 2, 'to': 1, 'words': 1, 'yes': 1}
根据tips,写一段python代码,先将text的标点全部替换成空格并转换小写后,利用空格符号作为分隔符将text分割成数组,并循环遍历数组计数,以下为代码和运行结果
任务二:完成一份debug笔记
运行到第一个断点时,text为左上角的一串字符串
运行到第二个断点时,已经将text的内容全部替换成空格符号
运行到下个断点时,可以看到words的分割后的内容已经显示出来了