题目描述:
代码1:
class Solution:
def mostCommonWord(self, paragraph, banned):
"""
:type paragraph: str
:type banned: List[str]
:rtype: str
"""
list1=[]
listout=[]
paragraph=paragraph.lower()
for i in paragraph:
if(not i.isalpha() and i!=' '):
paragraph=paragraph.replace(i,'')
#paragraph.lower()
list1=paragraph.split()
length=len(list1)
k=0
while(k<length):
if(banned.count(list1[k])!=0):
list1.pop(k)
length-=1
continue
k+=1
for j in list1:
listout.append(list1.count(j))
return list1[listout.index(max(listout))]
总结: