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)
根据我对标题中问题的理解,没有太多细节,这是一种方法。wordList是要查找的源列表,inList是输入。在
输出:
^{pr2}$相关问题 更多 >
编程相关推荐