0
例如,如果我有没有任何标点符号的字符串:计算每个单词在一个字符串中重复的次数?
"She walked the dog to the park and played ball with the dog When she threw the ball to the dog the dog missed the ball and ran to the other side of the park to fetch it"
我知道如何将字符串转换为大写/小写和使用功能
from collections import Counter
做到这一点,但我不能想想没有使用内置函数(包括set.default,get,sorted等)的任何其他方式来计数
它应该以key:value格式出现。有任何想法吗?