问题如下
def split_on_separators(original, separators):
""" (str, str) -> list of str
Return a list of non-empty, non-blank strings from original,
determined by splitting original on any of the separators.
separators is a string of single-character separators.
>>> split_on_separators("Hooray! Finally, we're done.", "!,")
['Hooray', ' Finally', " we're done."]
我写的是
result = [original]
for i in separators:
original = original.replace(i, '>>.<')
result = original.split('>>.<')
for word in result:
if word == '':
result.remove(word)
return result
可是我试了 "this is the first sentence. Isn't it? Yes ! !! This" 的话得到答案里有很多符号, 不知道怎么改
不能从我有的基础改吗?
追答你这是替换掉了原来里面的“i”??