我想要翻译一段文本,它看起来像这样:
并返回:
那就是说,我想要删除重复的单词,并用 "." 替换它们。这是我开始编写代码的方式:
我的逻辑是创建一个包含所有字符串中最差的单词的列表,并将每个单词添加到新列表中,如果该单词已经在列表中,则用“.”替换它。我的代码返回[]。如有建议,非常感谢!
。
Engineering will save the world from inefficiency. Inefficiency is a blight on the world and its humanity.
并返回:
Engineering will save the world from inefficiency..is a blight on the . and its humanity.
那就是说,我想要删除重复的单词,并用 "." 替换它们。这是我开始编写代码的方式:
lines= ["Engineering will save the world from inefficiency.",
"Inefficiency is a blight on the world and its humanity."]
def solve(lines):
clean_paragraph = []
for line in lines:
if line not in str(lines):
clean_paragraph.append(line)
print (clean_paragraph)
if word == word in line in clean_paragraph:
word = "."
return clean_paragraph
我的逻辑是创建一个包含所有字符串中最差的单词的列表,并将每个单词添加到新列表中,如果该单词已经在列表中,则用“.”替换它。我的代码返回[]。如有建议,非常感谢!