count = 0
for word in newWordList:
newWordList= word.count('theBells')
count += 1
print(newWordList)
答案 0 :(得分:0)
根据我对标题中的问题的解释,并没有太多细节,这是一种方法。 wordList是你要查找的源列表,inList是输入。
count = 0
wordList=["hello","hi","is","and", "are", "you"]
#'are' appears twice and 'you' once - total should be 3
inList=["how", "are","you", "where", "are", "your", "friends" ]
count = 0
#count number of times the words in wordList appear in the input list 'inList'
for word in inList:
if word in wordList:
count += 1
print(count)
<强>输出:强>
3