我的列表:
city=['Venango Municiplaity', 'Waterford ship','New York']
预期结果:
city = ['Venango Municiplaity ', 'Waterford ship','New York','Venango','Waterford']
常用的词:
common_words = ['ship','municipality']
扫描我的列表中的所有项目,去掉常用词并重新插入到同一个列表中,如预期结果所示。
我能够搜索包含常用词的项目,但不确定如何将其替换为空白并重新插入“我的列表”中。
到目前为止我的代码:
for item in city:
if(any(x in s.lower() for s in item.split(' ') for x in common_words)) :
神不在的星期二
四季花海
相关分类