如何使用loop
. 例如,假设我有一个function
名为“ changeWords
”,我希望这个函数将三个单词can't、should not、don't更改为can't、should not、do not。所以当输入函数时,'changeWords("I don't know how to do this")'
应该返回'I do not know how to do this".
澄清:
changeWords(“I can't eat") -> “I can not eat"
changeWords(“I don't like swimming.”) -> “I do not like swimming.”
changeWords(“I shouldn't do that.”) -> “I should not do that.”
我的尝试:
def stringChange(a):
a = ""
for line in stringChange("a"):
line = text.replace("a","can't","can not")
if not line: break
return line