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格式出現。有任何想法嗎?