给定一个string数组article及其大小n及一个待统计单词word,请返回该单词在数组中出现的频数。文章的词数在1000以内。
return article.count(word)
class Frequency: def getFrequency(self, article, n, word): return article.count(word)
class Frequency: def getFrequency(self, article, n, word): # write code here count = 0 for item in article: if item == word: count += 1 return count
这道题你会答吗?花几分钟告诉大家答案吧!
扫描二维码,关注牛客网
下载牛客APP,随时随地刷题